run.py 913 B

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- encoding: utf-8 -*-
  2. """
  3. Copyright (c) 2019 - present AppSeed.us
  4. """
  5. import os
  6. from flask_migrate import Migrate
  7. from sys import exit
  8. from apps.config import config_dict
  9. from apps import create_app, db
  10. # WARNING: Don't run with debug turned on in production!
  11. DEBUG = (os.getenv('DEBUG', 'False') == 'True')
  12. # The configuration
  13. get_config_mode = 'Debug' if DEBUG else 'Production'
  14. try:
  15. # Load the configuration using the default values
  16. app_config = config_dict[get_config_mode.capitalize()]
  17. except KeyError:
  18. exit('Error: Invalid <config_mode>. Expected values [Debug, Production] ')
  19. app = create_app(app_config)
  20. Migrate(app, db)
  21. if DEBUG:
  22. app.logger.info('DEBUG = ' + str(DEBUG) )
  23. app.logger.info('DBMS = ' + app_config.SQLALCHEMY_DATABASE_URI)
  24. app.logger.info('ASSETS_ROOT = ' + app_config.ASSETS_ROOT )
  25. if __name__ == "__main__":
  26. app.run()