run.py 1023 B

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