Support compressed files in send_file() (Fixes #93)

This commit is contained in:
Miguel Grinberg
2023-03-21 00:15:24 +00:00
parent e684ee32d9
commit daf1001ec5
6 changed files with 60 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
from microdot import Microdot, send_file
app = Microdot()
@app.route('/')
def index(request):
return send_file('gzstatic/index.html', compressed=True,
file_extension='.gz')
@app.route('/static/<path:path>')
def static(request, path):
if '..' in path:
# directory traversal is not allowed
return 'Not found', 404
return send_file('gzstatic/' + path, compressed=True, file_extension='.gz')
app.run(debug=True)

Binary file not shown.

Binary file not shown.