config.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """Configuration settings for the Flask application."""
  2. import os
  3. basedir = os.path.abspath(os.path.dirname(__file__))
  4. class Config:
  5. """Base configuration."""
  6. SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key')
  7. SQLALCHEMY_TRACK_MODIFICATIONS = False
  8. # API settings
  9. RESTX_MASK_SWAGGER = False
  10. RESTX_ERROR_404_HELP = False
  11. # JWT settings
  12. JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY', 'jwt-dev-secret-key')
  13. JWT_EXPIRATION_DAYS = 7
  14. JWT_ALGORITHM = 'HS256'
  15. class DevelopmentConfig(Config):
  16. """Development configuration."""
  17. DEBUG = True
  18. SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
  19. 'sqlite:///' + os.path.join(basedir, '..', 'dev.db')
  20. class TestingConfig(Config):
  21. """Testing configuration with SQLite."""
  22. TESTING = True
  23. SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
  24. class ProductionConfig(Config):
  25. """Production configuration with PostgreSQL."""
  26. DEBUG = False
  27. SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
  28. 'postgresql://localhost/work_statistics'
  29. config = {
  30. 'default': DevelopmentConfig,
  31. 'development': DevelopmentConfig,
  32. 'testing': TestingConfig,
  33. 'production': ProductionConfig
  34. }