From 4182581f3d540d0a3c95d212c120e2080d18f7cd Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 22 Dec 2024 23:59:10 +0100 Subject: use delayed db initialisation to allow parsing parameters in main --- halfnarp2.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'halfnarp2.py') diff --git a/halfnarp2.py b/halfnarp2.py index ebd6f6b..5451411 100755 --- a/halfnarp2.py +++ b/halfnarp2.py @@ -12,15 +12,6 @@ import markdown from html_sanitizer import Sanitizer from hashlib import sha256 -app = Flask(__name__) -app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://halfnarp@localhost:5432/halfnarp" -app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False -app.config["SERVER_NAME"] = "halfnarp.events.ccc.de" -app.config["SECRET_KEY"] = "" -app.jinja_env.trim_blocks = True -app.jinja_env.lstrip_blocks = True -CORS(app) - db = SQLAlchemy(app) @@ -276,6 +267,19 @@ if __name__ == "__main__": config["pretalx-url"] + "api/events/" + config["pretalx-conference"] ) + app = Flask(__name__) + app.config["SQLALCHEMY_DATABASE_URI"] = config.get( + "database-uri", "sqlite:///test.db" + ) + app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False + app.config["SERVER_NAME"] = config.get("server-name", "localhost") + app.config["SECRET_KEY"] = "" + app.jinja_env.trim_blocks = True + app.jinja_env.lstrip_blocks = True + CORS() + + db.init(app) + with app.app_context(): db.create_all() if args.pretalx_import: -- cgit v1.2.3