dankventskalender migrate to flask
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

42 lines
1007B

  1. import os
  2. from flask import Flask
  3. def create_app(test_config=None):
  4. # create and configure the app
  5. app = Flask(__name__, instance_relative_config=True)
  6. app.config.from_mapping(
  7. SECRET_KEY='dev',
  8. DATABASE=os.path.join(app.instance_path, 'calender.sqlite'),
  9. )
  10. if test_config is None:
  11. # load the instance config, if it exists, when not testing
  12. app.config.from_pyfile('config.py', silent=True)
  13. else:
  14. # load the test config if passed in
  15. app.config.from_mapping(test_config)
  16. # ensure the instance folder exists
  17. try:
  18. os.makedirs(app.instance_path)
  19. except OSError:
  20. pass
  21. # a simple page that says hello
  22. @app.route('/hello')
  23. def hello():
  24. return 'Hello, World!'
  25. from . import db
  26. db.init_app(app)
  27. from . import auth
  28. app.register_blueprint(auth.bp)
  29. from . import calender
  30. app.register_blueprint(calender.bp)
  31. app.add_url_rule('/', endpoint='index')
  32. return app