appstore: implement a proper config mechanism

This commit is contained in:
Alexandre Aubin
2023-08-17 13:57:32 +02:00
parent 96ce63d392
commit 83075de5dd
3 changed files with 25 additions and 7 deletions

View File

@ -1,4 +1,4 @@
from flask import Flask, send_from_directory, render_template, session, redirect, request
import toml
import base64
import hashlib
import hmac
@ -6,16 +6,28 @@ import os
import random
import urllib
import json
from settings import DISCOURSE_SSO_SECRET, DISCOURSE_SSO_ENDPOINT, CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE
import sys
from flask import Flask, send_from_directory, render_template, session, redirect, request
app = Flask(__name__)
app.debug = True
app.config["DEBUG"] = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
catalog = json.load(open("apps.json"))
catalog['categories'] = {c['id']:c for c in catalog['categories']}
try:
config = toml.loads(open("config.toml").read())
DISCOURSE_SSO_SECRET = config["DISCOURSE_SSO_SECRET"]
DISCOURSE_SSO_ENDPOINT = config["DISCOURSE_SSO_ENDPOINT"]
CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE = config["CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE"]
except Exception as e:
print("You should create a config.toml with the appropriate key/values, cf config.toml.example")
print(e)
sys.exit(1)
if config.get("DEBUG"):
app.debug = True
app.config["DEBUG"] = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
category_color = {
"synchronization": "sky",
"publishing": "yellow",