-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
49 lines (44 loc) · 1.62 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import json
basedir = os.path.abspath(os.path.dirname(__file__))
secrets = None
with open('secrets.json', 'r') as secrets_file:
secrets = json.load(secrets_file)['PRODUCTION']
class DefaultConfig:
DEBUG = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
SQLALCHEMY_TRACK_MODIFICATIONS = False
WTF_CSRF_ENABLED = True
SECRET_KEY = secrets['SECRET_KEY']
MAX_CONTENT_LENGTH = 1 * 1024 * 1024 # 1 Mb limit
ALLOWED_EXTENSIONS = ['txt']
UPLOAD_FOLDER = os.path.join(basedir, "submissions")
# email server
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 465
MAIL_USE_TLS = False
MAIL_USE_SSL = True
MAIL_USERNAME = secrets['MAIL_USERNAME']
MAIL_PASSWORD = secrets['MAIL_PASSWORD']
MAIL_DEFAULT_SENDER = "[email protected]"
# administrator list
ADMINS = [secrets['MAIL_USERNAME']]
SECURITY_PASSWORDLESS = True
SECURITY_TOKEN_AUTHENTICATION_KEY= secrets['SECRET_KEY']
SECURITY_TOKEN_MAX_AGE = 604800 # 1 week
SECURITY_EMAIL_SENDER = 'no-reply@localhost'
# Temp workaround
USERS_PATH = os.path.join(basedir, 'users.csv')
MASTER_FILE = os.path.join(basedir, 'master.txt')
REGISTRATION_FILE = os.path.join(basedir, 'registration.csv')
SUPERUSERS = secrets["SUPERUSERS"]
SECURITY_POST_LOGIN_VIEW = 'index'
class DebugConfig(DefaultConfig):
DEBUG = True
class ProductionConfig(DefaultConfig):
DEBUG = False
if("gunicorn" in os.environ.get("SERVER_SOFTWARE", "")):
current = ProductionConfig()
else:
current = DebugConfig()