mirror of
https://github.com/YunoHost/yunodevtools.git
synced 2024-09-03 20:16:19 +02:00
appstore: implement a proper config mechanism
This commit is contained in:
parent
a52c769abc
commit
b4a30b3f80
3 changed files with 25 additions and 7 deletions
1
store/.gitignore
vendored
Normal file
1
store/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config.toml
|
26
store/app.py
26
store/app.py
|
@ -1,4 +1,4 @@
|
||||||
from flask import Flask, send_from_directory, render_template, session, redirect, request
|
import toml
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
|
@ -6,16 +6,28 @@ import os
|
||||||
import random
|
import random
|
||||||
import urllib
|
import urllib
|
||||||
import json
|
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 = Flask(__name__)
|
||||||
|
|
||||||
app.debug = True
|
|
||||||
app.config["DEBUG"] = True
|
|
||||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
|
||||||
|
|
||||||
catalog = json.load(open("apps.json"))
|
catalog = json.load(open("apps.json"))
|
||||||
catalog['categories'] = {c['id']:c for c in catalog['categories']}
|
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 = {
|
category_color = {
|
||||||
"synchronization": "sky",
|
"synchronization": "sky",
|
||||||
"publishing": "yellow",
|
"publishing": "yellow",
|
||||||
|
|
5
store/config.toml.example
Normal file
5
store/config.toml.example
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# This secret is configured in Discourse
|
||||||
|
DISCOURSE_SSO_SECRET = "abcdefghijklmnopqrstuvwxyz1234567890"
|
||||||
|
DISCOURSE_SSO_ENDPOINT = "https://forum.yunohost.org/session/sso_provider"
|
||||||
|
CALLBACK_URL_AFTER_LOGIN_ON_DISCOURSE = "http://localhost:5000/sso_login_callback"
|
||||||
|
DEBUG = false
|
Loading…
Add table
Reference in a new issue