flask config py file

Solutions on MaxInterview for flask config py file by the best coders in the world

showing results for - "flask config py file"
Felipe
13 Nov 2020
1import os
2
3app_dir = os.path.abspath(os.path.dirname(__file__))
4
5class BaseConfig:
6    SECRET_KEY = os.environ.get('SECRET_KEY') or 'A SECRET KEY'
7    SQLALCHEMY_TRACK_MODIFICATIONS = False
8
9    ##### Flask-Mail configurations #####
10    MAIL_SERVER = 'smtp.googlemail.com'
11    MAIL_PORT = 587
12    MAIL_USE_TLS = True
13    MAIL_USERNAME = os.environ.get('MAIL_USERNAME') or 'infooveriq@gmail.com'
14    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') or 'password'
15    MAIL_DEFAULT_SENDER = MAIL_USERNAME
16
17
18class DevelopementConfig(BaseConfig):
19    DEBUG = True
20    SQLALCHEMY_DATABASE_URI = os.environ.get('DEVELOPMENT_DATABASE_URI') or  \
21        'mysql+pymysql://root:pass@localhost/flask_app_db'
22    
23
24class TestingConfig(BaseConfig):
25    DEBUG = True
26    SQLALCHEMY_DATABASE_URI = os.environ.get('TESTING_DATABASE_URI') or \
27                              'mysql+pymysql://root:pass@localhost/flask_app_db'    
28
29class ProductionConfig(BaseConfig):
30    DEBUG = False
31    SQLALCHEMY_DATABASE_URI = os.environ.get('PRODUCTION_DATABASE_URI') or  \
32        'mysql+pymysql://root:pass@localhost/flask_app_db'
33