config.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- encoding: utf-8 -*-
  2. """
  3. Copyright (c) 2019 - present AppSeed.us
  4. """
  5. import os
  6. class Config(object):
  7. basedir = os.path.abspath(os.path.dirname(__file__))
  8. # Set up the App SECRET_KEY
  9. # SECRET_KEY = config('SECRET_KEY' , default='S#perS3crEt_007')
  10. SECRET_KEY = os.getenv('SECRET_KEY', 'S#perS3crEt_007')
  11. # This will create a file in <app> FOLDER
  12. SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'db.sqlite3')
  13. SQLALCHEMY_TRACK_MODIFICATIONS = False
  14. # Assets Management
  15. ASSETS_ROOT = os.getenv('ASSETS_ROOT', '/static/assets')
  16. class ProductionConfig(Config):
  17. DEBUG = False
  18. # Security
  19. SESSION_COOKIE_HTTPONLY = True
  20. REMEMBER_COOKIE_HTTPONLY = True
  21. REMEMBER_COOKIE_DURATION = 3600
  22. # PostgreSQL database
  23. SQLALCHEMY_DATABASE_URI = '{}://{}:{}@{}:{}/{}'.format(
  24. os.getenv('DB_ENGINE' , 'mysql'),
  25. os.getenv('DB_USERNAME' , 'appseed_db_usr'),
  26. os.getenv('DB_PASS' , 'pass'),
  27. os.getenv('DB_HOST' , 'localhost'),
  28. os.getenv('DB_PORT' , 3306),
  29. os.getenv('DB_NAME' , 'appseed_db')
  30. )
  31. class DebugConfig(Config):
  32. DEBUG = True
  33. # Load all possible configurations
  34. config_dict = {
  35. 'Production': ProductionConfig,
  36. 'Debug' : DebugConfig
  37. }