{"library":"mimesniff","title":"mimesniff","description":"A pure Python implementation of the MIME sniffing algorithm from the WHATWG MIME Sniffing specification. Version 1.1.1 supports Python >=3.4 and allows sniffing MIME types from file-like objects or pre-read headers. Uses a decision tree based on byte patterns. Released infrequently.","language":"python","status":"active","last_verified":"Fri May 01","install":{"commands":["pip install mimesniff"],"cli":null},"imports":["from mimesniff import MimeSniffer","from mimesniff import sniff"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import io\nfrom mimesniff import sniff\n\n# Example from bytes\nmime_type = sniff(b'%PDF-1.4')\nprint(mime_type)  # application/pdf\n\n# Example from file-like object\nwith open('example.html', 'rb') as f:\n    mime_type = sniff(f)\n    print(mime_type)  # text/html","lang":"python","description":"Call sniff() with bytes or a file-like object (opened in binary mode) to get the sniffed MIME type as a string.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}