Без опису

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. from flask import Flask
  3. def create_app(test_config=None):
  4. app = Flask(__name__, instance_relative_config=True)
  5. app.config.from_mapping(
  6. SECRET_KEY='dev',
  7. DATABASE=os.path.join(app.instance_path, 'upr_espera.sqlite'),
  8. )
  9. if test_config is None:
  10. app.config.from_pyfile('config.py', silent=True)
  11. else:
  12. app.config.from_mapping(test_config)
  13. try:
  14. os.makedirs(app.instance_path)
  15. except OSError:
  16. pass
  17. from . import db
  18. db.init_app(app)
  19. from . import index
  20. app.register_blueprint(index.bp)
  21. app.add_url_rule('/', endpoint='index')
  22. from . import admin_insert
  23. app.register_blueprint(admin_insert.bp)
  24. app.add_url_rule('/admin_insert', endpoint='admin_insert')
  25. return app