This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
47 lines (37 loc) · 1.67 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
import os,uuid
BASEDIR = os.path.dirname(__file__)
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or uuid.uuid4().hex # default uuid, if not provided
FLASK_INSTANCE_PATH = os.environ.get('FLASK_INSTANCE_PATH') or BASEDIR
SAMPLESHEET_SCHEMA = os.environ.get('SAMPLESHEET_SCHEMA') or None
METADATA_SCHEMA = os.environ.get('METADATA_SCHEMA') or None
RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY') or None
RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY') or None
RECAPTCHA_API_SERVER = os.environ.get('RECAPTCHA_API_SERVER') or 'https://www.google.com/recaptcha/api/siteverify'
SQLALCHEMY_TRACK_MODIFICATIONS = os.environ.get('SQLALCHEMY_TRACK_MODIFICATIONS') or False
@staticmethod
def init_app(app):
pass
class DevConfig(Config):
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') or \
'sqlite:////{0}/dev_database.sqlite'.format(BASEDIR)
class TestConfig(Config):
WTF_CSRF_ENABLED = False
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URI') or \
'sqlite:////{0}/test_database.sqlite'.format(BASEDIR)
class ProdConfig(Config):
SQLALCHEMY_DATABASE_URI = os.environ.get('PROD_DATABASE_URI') or None
class CloudConfiig(ProdConfig):
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') or None
@classmethod
def init_app(cls,app):
import logging
from logging import StreamHandler
file_handler = StreamHandler()
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
config = {'development':DevConfig,
'testing':TestConfig,
'production':ProdConfig,
'cloud':CloudConfiig
}