-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.py
55 lines (43 loc) · 1.23 KB
/
index.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
48
49
50
51
52
53
54
55
from pathlib import Path
import flask
from flask_compress import Compress
from flask_cors import CORS
import waitress
import config
import gen_example_data
from prod import PROD
# Register blueprints
from routes.auth import auth
from routes.comments import comments
from routes.moderation import mod
from routes.notifications import notifs
from routes.projects import projects
from routes.user import user
from routes.versions import versions
app = flask.Flask(__name__)
CORS(app, supports_credentials=True)
Compress(app)
@app.route("/")
def main():
return "I see you discovered our API 👀 why hello there"
@app.after_request
def after(response):
response.headers["X-Robots-Tag"] = "noindex"
return response
app.register_blueprint(user)
app.register_blueprint(auth)
app.register_blueprint(projects)
app.register_blueprint(versions)
app.register_blueprint(mod)
app.register_blueprint(notifs)
app.register_blueprint(comments)
# Database things
if not Path(config.DATA + "data.db").exists():
gen_example_data.reset("no-drop")
# Run the app
if __name__ == "__main__":
debug_enabled = PROD == 0
if debug_enabled:
app.run()
else:
waitress.serve(app)