-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (39 loc) · 1.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import flask
from flask import render_template, request
from globals import app
from helpers import init
from routes import user
from routes.api_interact import api_interact
from routes.api_create import api_create
from routes.api_get import api_get
from routes.api_moderate import api_moderate
from routes.permissions import api_permissions
from statics import config
app.debug = True
init.init_db()
app.register_blueprint(user.user_management)
app.register_blueprint(api_get)
app.register_blueprint(api_create)
app.register_blueprint(api_permissions)
app.register_blueprint(api_moderate)
app.register_blueprint(api_interact)
@app.errorhandler(404)
def react(*args, **kwargs):
if request.path.startswith("/api/"):
return "Endpoint not found", 404
return app.send_static_file("index.html")
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
Credit: https://stackoverflow.com/a/34067710
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
r.headers["Access-Control-Allow-Origin"] = "*"
return r
if __name__ == "__main__":
app.run("0.0.0.0", config.port)