diff options
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | app.py | 12 | ||||
| -rw-r--r-- | config-template.py | 8 | ||||
| -rw-r--r-- | config.json.template | 9 |
4 files changed, 21 insertions, 13 deletions
@@ -1,4 +1,3 @@ -votes.db -votes*.db -config.py +*.db +*.json __pycache__/ @@ -4,6 +4,7 @@ import sqlite3 import hashlib import os import re +import json import datetime from flask import ( Flask, @@ -17,7 +18,6 @@ from flask import ( session, flash ) -from config import config class Markup(object): @@ -513,7 +513,7 @@ class DBProxy(object): def db(): database = getattr(g, "_database", None) if database is None: - database = g._database = DBProxy("votes.db", + database = g._database = DBProxy(config['database'], config['superuser'].lower()) return database @@ -677,6 +677,14 @@ def get_static(path): def robotstxt(): return send_from_directory('static', 'robots.txt') +if 'VOTE_CONFIG' in os.environ: + configf = open(os.environ['VOTE_CONFIG']) +else: + configf = open('config.json') + +config = json.load(configf) +configf.close() + app.debug = config['debug'] app.secret_key = config['secret_key'] if __name__ == '__main__': diff --git a/config-template.py b/config-template.py deleted file mode 100644 index 2fc1310..0000000 --- a/config-template.py +++ /dev/null @@ -1,8 +0,0 @@ -config = { - 'secret_key': b'', - 'debug': False, - 'superuser': 'admin', - 'abusemail': 'admin@host.example.com', - 'featured': ['sticky'], - 'title': 'My awesome voting page' -} diff --git a/config.json.template b/config.json.template new file mode 100644 index 0000000..888d11e --- /dev/null +++ b/config.json.template @@ -0,0 +1,9 @@ +{ + "database": "votes.db", + "secret_key": "", + "debug": false, + "superuser": "admin", + "abusemail": "admin@host.example.com", + "featured": ["sticky"], + "title": "My awesome voting page" +} |
