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)
|
||||
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:")
|
||||
if not ENABLE_TIMING:
|
||||
print("- Disabled timing constraints")
|
||||
if ENABLE_DEBUG_ENDPOINTS:
|
||||
print("- Enabled debug endpoints")
|
||||
|
||||
app: Flask = Flask(__name__)
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///formula10.db"
|
||||
|
@ -2,11 +2,12 @@ from typing import List
|
||||
from urllib.parse import unquote
|
||||
from flask import redirect, render_template, request
|
||||
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.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 import app
|
||||
from formula10 import ENABLE_DEBUG_ENDPOINTS, app
|
||||
|
||||
|
||||
@app.route("/save/all")
|
||||
@ -15,11 +16,14 @@ def save() -> Response:
|
||||
return redirect("/")
|
||||
|
||||
|
||||
# @app.route("/load/all")
|
||||
# def load() -> Response:
|
||||
# reload_static_data()
|
||||
# reload_dynamic_data()
|
||||
# return redirect("/")
|
||||
@app.route("/load/all")
|
||||
def load() -> Response:
|
||||
if not ENABLE_DEBUG_ENDPOINTS:
|
||||
return error_redirect("Debug endpoints are disabled!")
|
||||
|
||||
reload_static_data()
|
||||
reload_dynamic_data()
|
||||
return redirect("/")
|
||||
|
||||
|
||||
@app.route("/load/static")
|
||||
@ -34,10 +38,13 @@ def load_season_results() -> Response:
|
||||
return redirect("/")
|
||||
|
||||
|
||||
# @app.route("/load/dynamic")
|
||||
# def load_dynamic() -> Response:
|
||||
# reload_dynamic_data()
|
||||
# return redirect("/")
|
||||
@app.route("/load/dynamic")
|
||||
def load_dynamic() -> Response:
|
||||
if not ENABLE_DEBUG_ENDPOINTS:
|
||||
return error_redirect("Debug endpoints are disabled!")
|
||||
|
||||
reload_dynamic_data()
|
||||
return redirect("/")
|
||||
|
||||
|
||||
@app.route("/result")
|
||||
|
Reference in New Issue
Block a user