messing around with flask tutorial

__init__.py 779B

123456789101112131415161718192021222324252627282930313233343536
  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, 'flaskr.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. @app.route('/hello')
  18. def hello():
  19. return 'Hello, World!'
  20. from . import db
  21. db.init_app(app)
  22. from . import auth
  23. app.register_blueprint(auth.bp)
  24. from . import blog
  25. app.register_blueprint(blog.bp)
  26. app.add_url_rule('/', endpoint='index')
  27. return app