__init__.py 944 B

1234567891011121314151617181920212223242526272829303132333435
  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, "flaskr.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. os.makedirs(app.instance_path, exist_ok=True)
  18. # a simple page that says hello
  19. @app.route("/health")
  20. def health():
  21. return "Health check passed!"
  22. from . import home
  23. app.register_blueprint(home.bp, url_prefix="/")
  24. from . import questions
  25. app.register_blueprint(questions.bp, url_prefix="/api/questions")
  26. return app