Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app = Flask(__name__)
- app.config.from_object('yourapplication.Config')
- class Config(object):
- DEBUG = True
- TESTING = False
- DB_USER = os.getenv("DB_USER", "db_user")
- DB_PASSWORD = os.getenv("DB_PASSWORD", "db_password")
- DB_HOST = os.getenv("DB_HOST", "localhost") # 127.0.0.1"
- DB_PORT = os.getenv("DB_PORT", "5555")
- DB_SCHEMA = "my_schema"
- DB_DATABASE_NAME = "my_database"
- SQLALCHEMY_DATABASE_URI = "postgresql://{}:{}@{}:{}/{}".format(
- DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE_NAME)
- SQLALCHEMY_TRACK_MODIFICATIONS = False
- my_flask_app cmd1 arg1 arg2
- DEBUG=true DB_PORT=1234 my_flask_app cmd1 arg1 arg2
- class BaseConfig:
- DEBUG = False
- TESTING = False
- SECRET_KEY = os.getenv('SECRET_KEY', 'a default secret key')
- ...
- class DevelopmentConfig(BaseConfig):
- DEBUG = True
- ...
- class TestingConfig(BaseConfig):
- TESTING = True
- ...
- class ProductionConfig(BaseConfig):
- ...
- app = Flask(__name__)
- app_settings = os.getenv(
- 'APP_SETTINGS',
- 'app.config.DevelopmentConfig'
- )
- app.config.from_object(app_settings)
- > APP_SETTINGS=app.config.TestingConfig my_flask_app cmd1 arg1 arg2
Add Comment
Please, Sign In to add comment