-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathrunner.py
55 lines (38 loc) · 1.45 KB
/
runner.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
"""Test Runner Module for Local Running."""
from flask import send_from_directory, Flask
import os
import sys
from swagger_ui import flask_api_doc
import secrets
os.environ["WORKER_URL_DEV"] = "http://localhost:8000"
os.environ["TEST_REDIS"] = "1"
sys.path.append("worker")
sys.path.append("controller")
# Prepend all routes with /api
from worker.worker import api as worker_api # noqa
from controller.app import ALLOWED_REFERRERS, API_KEYS, api # noqa
from controller.app import admin_portal # noqa
app = Flask(__name__, static_folder="", template_folder="templates")
flask_api_doc(app, config_path="./controller/swagger.yaml", url_prefix="/api/doc", title="API doc")
app.register_blueprint(api)
app.register_blueprint(worker_api)
secret_token = secrets.token_hex(256)
app.config["SECRET_KEY"] = secret_token
@app.route("/")
def index():
"""Serve the index page."""
return send_from_directory(".", "index.html")
@app.route("/randomizer")
def rando():
"""Serve the randomizer page."""
return send_from_directory(".", "randomizer.html")
@app.route("/privacy")
def privacy():
"""Serve the privacy page."""
return send_from_directory(".", "privacy.html")
# Its a full function not a blueprint so we need to register it as a route
app.add_url_rule("/admin", view_func=admin_portal)
ALLOWED_REFERRERS.extend(["*"])
API_KEYS.append("LOCAL_API_KEY")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000, threaded=True, debug=True)