This commit is contained in:
2025-08-30 10:30:43 +02:00
commit 202019208e
35 changed files with 2328 additions and 0 deletions

30
schnitzeljagt/__main__.py Normal file
View File

@ -0,0 +1,30 @@
from pathlib import Path
from .core import app
# Start the flask server if run from terminal
if __name__ == "__main__":
@app.route('/')
def get_root():
return app.send_static_file('index.html')
@app.route('/<path:path>')
def get_path(path):
fpath = f"{app.static_folder}/{path}"
# Prettier URLs by auto-loading <path>.html
# Our nginx config does this as well
if not Path(fpath).is_file():
return app.send_static_file(path + '.html')
return app.send_static_file(path)
# Just allow everything to avoid the hassle when running locally.
@app.after_request
def add_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = '*'
response.headers['Access-Control-Allow-Headers'] = '*'
return response
app.run(host='0.0.0.0')