-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
57 lines (39 loc) · 1.29 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
48
49
50
51
52
53
54
55
56
57
from flask import request, abort, send_from_directory, render_template
from flask_restful import Api
from app import app
from resources.project import Project
from resources.run import Run
api = Api(app)
api.add_resource(Project, "/project")
api.add_resource(Run, "/run")
@app.route("/run/uploadZip", methods=["GET", "POST"])
def upload_zip():
return Run.upload_zip()
@app.route("/run/<report_id>/report/<report_type>", methods=["GET"])
def get_report(report_id, report_type):
return Run.get_report(report_id, report_type)
@app.route("/static/<path:path>")
def static_files(path):
return send_from_directory("static", path)
@app.route("/docs")
@app.route("/")
def docs():
return render_template("docs.html")
@app.before_first_request
def create_tables():
# db.drop_all()
db.create_all()
@app.before_request
def check_for_token():
if app.debug or request.path == "/" or request.path == "/docs":
return
try:
if not request.headers["Authorization"] == f"Bearer {app.config['AUTH_TOKEN']}":
abort(403)
except Exception as e:
app.logger.warn("No auth possible", e)
abort(403)
if __name__ == "__main__":
from db import db
db.init_app(app)
app.run(host='0.0.0.0', port=app.config["PORT"], debug=app.config["DEBUG"])