Allow enabling debug endpoints with env var
This commit is contained in:
@ -4,9 +4,12 @@ from flask_sqlalchemy import SQLAlchemy
|
|||||||
|
|
||||||
# Load local ENV variables (can be set when calling the executable)
|
# Load local ENV variables (can be set when calling the executable)
|
||||||
ENABLE_TIMING: bool = False if os.getenv("DISABLE_TIMING") == "True" else True
|
ENABLE_TIMING: bool = False if os.getenv("DISABLE_TIMING") == "True" else True
|
||||||
|
ENABLE_DEBUG_ENDPOINTS: bool = True if os.getenv("ENABLE_DEBUG_ENDPOINTS") == "True" else False
|
||||||
print("Running Formula10 with:")
|
print("Running Formula10 with:")
|
||||||
if not ENABLE_TIMING:
|
if not ENABLE_TIMING:
|
||||||
print("- Disabled timing constraints")
|
print("- Disabled timing constraints")
|
||||||
|
if ENABLE_DEBUG_ENDPOINTS:
|
||||||
|
print("- Enabled debug endpoints")
|
||||||
|
|
||||||
app: Flask = Flask(__name__)
|
app: Flask = Flask(__name__)
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db"
|
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db"
|
||||||
|
@ -2,11 +2,12 @@ from typing import List
|
|||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
from flask import redirect, render_template, request
|
from flask import redirect, render_template, request
|
||||||
from werkzeug import Response
|
from werkzeug import Response
|
||||||
|
from formula10.controller.error_controller import error_redirect
|
||||||
|
|
||||||
from formula10.database.update_queries import update_race_result, update_user
|
from formula10.database.update_queries import update_race_result, update_user
|
||||||
from formula10.database.import_export import export_dynamic_data, reload_season_guess_result_data, reload_static_data
|
from formula10.database.import_export import export_dynamic_data, reload_dynamic_data, reload_season_guess_result_data, reload_static_data
|
||||||
from formula10.domain.template_model import TemplateModel
|
from formula10.domain.template_model import TemplateModel
|
||||||
from formula10 import app
|
from formula10 import ENABLE_DEBUG_ENDPOINTS, app
|
||||||
|
|
||||||
|
|
||||||
@app.route("/save/all")
|
@app.route("/save/all")
|
||||||
@ -15,11 +16,14 @@ def save() -> Response:
|
|||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
|
|
||||||
# @app.route("/load/all")
|
@app.route("/load/all")
|
||||||
# def load() -> Response:
|
def load() -> Response:
|
||||||
# reload_static_data()
|
if not ENABLE_DEBUG_ENDPOINTS:
|
||||||
# reload_dynamic_data()
|
return error_redirect("Debug endpoints are disabled!")
|
||||||
# return redirect("/")
|
|
||||||
|
reload_static_data()
|
||||||
|
reload_dynamic_data()
|
||||||
|
return redirect("/")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/load/static")
|
@app.route("/load/static")
|
||||||
@ -34,10 +38,13 @@ def load_season_results() -> Response:
|
|||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
|
|
||||||
# @app.route("/load/dynamic")
|
@app.route("/load/dynamic")
|
||||||
# def load_dynamic() -> Response:
|
def load_dynamic() -> Response:
|
||||||
# reload_dynamic_data()
|
if not ENABLE_DEBUG_ENDPOINTS:
|
||||||
# return redirect("/")
|
return error_redirect("Debug endpoints are disabled!")
|
||||||
|
|
||||||
|
reload_dynamic_data()
|
||||||
|
return redirect("/")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/result")
|
@app.route("/result")
|
||||||
|
Reference in New Issue
Block a user