Reorganized examples into subdirectories

This commit is contained in:
Miguel Grinberg
2022-08-14 16:35:17 +01:00
parent 3c125c43d2
commit a01fc9c3f0
24 changed files with 6 additions and 0 deletions

19
examples/static/static.py Normal file
View File

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