No Description
python
flask

config.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import os
  2. basedir = os.path.abspath(os.path.dirname(__file__))
  3. class Config:
  4. SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
  5. MAIL_SERVER = os.environ.get('MAIL_SERVER', 'smtp.strato.de')
  6. MAIL_PORT = int(os.environ.get('MAIL_PORT', '587'))
  7. MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS', 'true').lower() in \
  8. ['true', 'on', '1']
  9. MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
  10. MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
  11. FLASKY_MAIL_SUBJECT_PREFIX = '[Flasky]'
  12. FLASKY_MAIL_SENDER = 'Flasky Admin <flasky@example.com>'
  13. FLASKY_ADMIN = os.environ.get('FLASKY_ADMIN')
  14. SQLALCHEMY_TRACK_MODIFICATIONS = False
  15. FLASKY_POSTS_PER_PAGE = 20
  16. FLASKY_FOLLOWERS_PER_PAGE = 50
  17. FLASKY_COMMENTS_PER_PAGE = 30
  18. @staticmethod
  19. def init_app(app):
  20. pass
  21. class DevelopmentConfig(Config):
  22. DEBUG = True
  23. SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
  24. 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')
  25. class TestingConfig(Config):
  26. TESTING = True
  27. SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
  28. 'sqlite://'
  29. class ProductionConfig(Config):
  30. SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
  31. 'sqlite:///' + os.path.join(basedir, 'data.sqlite')
  32. config = {
  33. 'development': DevelopmentConfig,
  34. 'testing': TestingConfig,
  35. 'production': ProductionConfig,
  36. 'default': DevelopmentConfig
  37. }