diff --git a/config.py.example b/config.py.example index 7c9da570301caae3dc5f6bd58a61ecd54ad27fc4..81862a504bab49b94015d0a03ca7d2a277aec8cc 100644 --- a/config.py.example +++ b/config.py.example @@ -1,13 +1,20 @@ -# Config for testing purposes only, don't run this in production! +# Defaults for development ,do not use in production! DEBUG = True +VIDEOPREFIX = 'https://videoag.fsmpi.rwth-aachen.de' +#SECRET_KEY = 'something random' +DB_SCHEMA = 'db_schema.sql' +DB_DATA = 'db_example.sql' + +#DB_ENGINE = 'mysql' #MYSQL_HOST = 'localhost' #MYSQL_USER = 'videoag' #MYSQL_PASSWD = 'somuchsecret' #MYSQL_DB = 'videos' -#DB_ENGINE = 'mysql' -SQLITE_DB = 'db.sqlite' DB_ENGINE = 'sqlite' +SQLITE_DB = 'db.sqlite' SQLITE_INIT_SCHEMA = True SQLITE_INIT_DATA = True + +#LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de' diff --git a/server.py b/server.py index 5695d412d123192c78223a0200f6214845ee35ab..9a9a76ce216b2cc17941351e1f2a8467b24c4fe4 100755 --- a/server.py +++ b/server.py @@ -4,6 +4,7 @@ from functools import wraps from datetime import date, timedelta, datetime, time, MINYEAR import threading import os +import sys import hashlib import random @@ -23,20 +24,15 @@ timer.daemon = True timer.start() config = app.config -config['DB_SCHEMA'] = 'db_schema.sql' -config['DB_DATA'] = 'db_example.sql' -config['DB_ENGINE'] = 'sqlite' -config['SQLITE_DB'] = 'db.sqlite' -config['SQLITE_INIT_SCHEMA'] = True -config['SQLITE_INIT_DATA'] = False -config['DEBUG'] = False -config['VIDEOPREFIX'] = 'https://videoag.fsmpi.rwth-aachen.de' -if __name__ == '__main__': - config['SQLITE_INIT_DATA'] = True - config['DEBUG'] = True +config.from_pyfile('config.py.example', silent=True) +if not sys.argv[0].endswith('run.py'): + config['SQLITE_INIT_DATA'] = False + config['DEBUG'] = False config.from_pyfile('config.py', silent=True) if config['DEBUG']: app.jinja_env.auto_reload = True +if not config.get('SECRET_KEY', None): + config['SECRET_KEY'] = os.urandom(24) from db import query, searchquery, ldapauth, ldapget, convert_timestamp