summaryrefslogtreecommitdiff
path: root/halfnarp2.py
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2024-12-22 23:59:10 +0100
committererdgeist <erdgeist@erdgeist.org>2024-12-22 23:59:10 +0100
commit4182581f3d540d0a3c95d212c120e2080d18f7cd (patch)
treef2a4fbd5744d767bd08411eee0e3a8649b01df2b /halfnarp2.py
parente3481a4a35091b32b6fbee80c1c9ba2b6d7b50d6 (diff)
use delayed db initialisation to allow parsing parameters in main
Diffstat (limited to 'halfnarp2.py')
-rwxr-xr-xhalfnarp2.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/halfnarp2.py b/halfnarp2.py
index ebd6f6b..5451411 100755
--- a/halfnarp2.py
+++ b/halfnarp2.py
@@ -12,15 +12,6 @@ import markdown
12from html_sanitizer import Sanitizer 12from html_sanitizer import Sanitizer
13from hashlib import sha256 13from hashlib import sha256
14 14
15app = Flask(__name__)
16app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://halfnarp@localhost:5432/halfnarp"
17app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
18app.config["SERVER_NAME"] = "halfnarp.events.ccc.de"
19app.config["SECRET_KEY"] = "<YOUR SERVER SECRET HERE>"
20app.jinja_env.trim_blocks = True
21app.jinja_env.lstrip_blocks = True
22CORS(app)
23
24db = SQLAlchemy(app) 15db = SQLAlchemy(app)
25 16
26 17
@@ -276,6 +267,19 @@ if __name__ == "__main__":
276 config["pretalx-url"] + "api/events/" + config["pretalx-conference"] 267 config["pretalx-url"] + "api/events/" + config["pretalx-conference"]
277 ) 268 )
278 269
270 app = Flask(__name__)
271 app.config["SQLALCHEMY_DATABASE_URI"] = config.get(
272 "database-uri", "sqlite:///test.db"
273 )
274 app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
275 app.config["SERVER_NAME"] = config.get("server-name", "localhost")
276 app.config["SECRET_KEY"] = "<YOUR SERVER SECRET HERE>"
277 app.jinja_env.trim_blocks = True
278 app.jinja_env.lstrip_blocks = True
279 CORS()
280
281 db.init(app)
282
279 with app.app_context(): 283 with app.app_context():
280 db.create_all() 284 db.create_all()
281 if args.pretalx_import: 285 if args.pretalx_import: