-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved support for compressed content #93
Comments
Would it help if |
That could be a possibility, however, there would also be cases where the server would not want to add the So I don't think the function can do it automatically, at least, without there being some kind of switch. Also, thanks for the fast reply! Highly appreciated! |
Yes, that's a good point. What you could do on your own to simplify your solution is to move all your compressed static files to a res = send_file(localPathGzip)
res.headers["Content-Encoding"] = "gzip"
return res I'll think about all the options and see what is the argument or set of arguments that make more sense to add. The other use case I would like to support is to optionally perform the compression of the file on the fly, which is probably not something you'd do on a microcontroller, but with Python would work okay. |
That would be possible yes, but would be somewhat hacky, however! You've made me realize something! send_file(localPathGzip, content_encoding="gzip", content_type=get_mime_type(url_path)) This could also enable what you want to do with encoding on-the-fly (at least if Does this look like something that could work for you? Also, keep in mind I might be a little biased with how the implementation (ie. adding |
This is how I added support for GZip
|
For my use case I am serving a lot of compressed static files, however, this does not seem like a case that has been thought into microdot.
For getting this to work, I am currently doing the following:
I am unsure of the best way to implement this, but maybe
send_file
could acceptcontentType
andcontentEncoding
, as well as moving the mime type detection into a separate function which accepts the filename/path as input (with optional set of default mime)?The text was updated successfully, but these errors were encountered: