larzmime
Look up a MIME type from a filename, no guessing.
A curated common subset (~50 types) covering the file types a real web app actually serves - not the full IANA registry, which is thousands of obscure entries most servers never need. is_text() answers the practical follow-up question: should this be served/edited as text.
larzscript pkg install mime
What you get
- ~50 curated, actually-common MIME types
- A clean application/octet-stream fallback
- is_text() - the practical follow-up question
- Extension lookup, case-insensitive
Try it
import "mime" as mime
print(mime.type_of("photo.jpg"))
print(mime.type_of("data.json"))
print(mime.type_of("weird.xyz"))
print(mime.is_text("style.css"))Output
image/jpeg application/json application/octet-stream true
Why it's in the Larz Stack
larzmime is a real Larzscript package (larzscript pkg install mime) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.