corona10 / mimesniff

Pure python mimesniff implementation of https://mimesniff.spec.whatwg.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mimesniff

https://travis-ci.org/corona10/mimesniff.svg?branch=master https://img.shields.io/pypi/v/mimesniff.svg?style=flat

Pure python mimesniff implementation of https://mimesniff.spec.whatwg.org

API interface is similar with API of python standard library

Install

pip install mimesniff

Usage

import mimesniff

res = mimesniff.what('sample.mp3')
print(res)
# audio/mpeg
with open('sample.mp3', 'rb') as fin:
    res = mimesniff.what(fin)
    print(res)
    # audio/mpeg

with open('sample.mp3', 'rb') as fin:
    header = fin.read(512)
    res = mimesniff.what(header)
    print(res)
    # audio/mpeg

About

Pure python mimesniff implementation of https://mimesniff.spec.whatwg.org

License:Apache License 2.0


Languages

Language:Python 100.0%