暂无描述

__init__.py 832B

12345678910111213141516171819202122232425262728293031
  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__)
  6. app.config.from_mapping(
  7. SECRET_KEY='dev', UPLOAD_FOLDER=os.path.join(
  8. app.root_path, "articles_files"), ALLOWED_EXTENSIONS={"txt"})
  9. if test_config is None:
  10. # load the instance config, if it exists, when not testing
  11. app.config.from_pyfile('config.py', silent=True)
  12. else:
  13. # load the test config if passed in
  14. app.config.from_mapping(test_config)
  15. # ensure the instance folder exists
  16. try:
  17. os.makedirs(app.instance_path)
  18. except OSError:
  19. pass
  20. from articles_api.articles.articles import articles_api_bp
  21. app.register_blueprint(articles_api_bp)
  22. app.add_url_rule('/', endpoint="index")
  23. return app