Guest User

Untitled

a guest
Dec 28th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. app = Flask(
  2.     __name__,
  3.     static_folder="./client/dist",
  4.     template_folder="./" + client_build_dir,  #  type: ignore
  5. )  # type: Flask
  6. app.session_interface = SecureCookieSession()
  7.  
  8. config_map = {
  9.     DEVELOPMENT: LocalConfig,
  10.     TESTING: TestingConfig,
  11.     STAGING: StagingConfig,
  12.     PRODUCTION: ProductionConfig,
  13. }
  14.  
  15. config = config_map[app.env]  # type: ignore
  16. app.config.from_object(config)
  17.  
  18. def _get_logger(log_level: str) -> logging.Logger:
  19.     logging.basicConfig(
  20.         level=log_level, format="%(asctime)s - %(levelname)s - %(message)s"
  21.     )
  22.     logger = logging.getLogger(__name__)
  23.     return logger
  24.  
  25. logger = _get_logger(config.LOG_LEVEL)  # type: logging.Logger
  26.  
  27. ####################### TestingConfig object used by testing environment
  28. class Config(object):
  29.     SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL")
  30.     DEBUG = False
  31.     TESTING = False
  32.     LOG_LEVEL = "INFO"
  33.     # ...
  34.  
  35. class TestingConfig(Config):
  36.     ENV = "testing"
  37.     TESTING = True
  38.     DEBUG = True
  39.     LOG_LEVEL = "DEBUG"
  40.     SQLALCHEMY_DATABASE_URI = TEST_SQLALCHEMY_DATABASE_URI
  41.     WEB_APP_DOMAIN = "http://localhost:5000/web"
  42.     WEB_APP_SERVER = "http://localhost:5000"
  43.  
Advertisement
Add Comment
Please, Sign In to add comment