nopaque/config.py

65 lines
1.9 KiB
Python
Raw Normal View History

2019-07-03 08:31:23 +00:00
import os
class Config:
2019-09-05 08:12:40 +00:00
''' ### Flask ### '''
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
''' ### Flask-Mail ### '''
2019-08-26 07:57:26 +00:00
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = int(os.environ.get('MAIL_PORT'))
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS').lower() == 'true'
2019-07-08 09:29:11 +00:00
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
2019-09-05 08:12:40 +00:00
MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')
''' ### Flask-SQLAlchemy ### '''
SQLALCHEMY_TRACK_MODIFICATIONS = False
2019-07-03 13:40:09 +00:00
2019-09-05 08:12:40 +00:00
''' ### Opaque ### '''
OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN')
2019-09-05 10:00:31 +00:00
OPAQUE_STORAGE_DIRECTORY = '/opaque_storage'
2019-09-05 08:12:40 +00:00
2019-07-03 13:40:09 +00:00
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
2019-09-05 08:12:40 +00:00
''' ### Flask ### '''
2019-07-03 13:40:09 +00:00
DEBUG = True
2019-09-05 12:43:36 +00:00
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir,
# 'data_dev.sqlite')
SQLALCHEMY_DATABASE_URI = \
'postgresql+psycopg2://{user}:{passwd}@{host}:{port}/{db}'.format(
user=os.environ.get('POSTGRES_USER'),
passwd=os.environ.get('POSTGRES_PASSWORD'),
host=os.environ.get('POSTGRES_HOST'),
port=os.environ.get('POSTGRES_PORT'),
db=os.environ.get('POSTGRES_DB_NAME'))
print(SQLALCHEMY_DATABASE_URI)
2019-07-03 13:40:09 +00:00
2019-09-05 08:12:40 +00:00
''' ### Flask-SQLAlchemy ### '''
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(
os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data_dev.sqlite')
)
2019-07-03 13:40:09 +00:00
class TestingConfig(Config):
''' ### Flask-SQLAlchemy ### '''
SQLALCHEMY_DATABASE_URI = 'sqlite://'
2019-09-05 08:12:40 +00:00
class ProductionConfig(Config):
''' ### Flask-SQLAlchemy ### '''
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
2019-07-03 13:40:09 +00:00
config = {
'development': DevelopmentConfig,
2019-07-08 08:52:36 +00:00
'testing': TestingConfig,
2019-09-05 08:12:40 +00:00
'production': ProductionConfig,
2019-07-03 13:40:09 +00:00
'default': DevelopmentConfig
}