__init__.py 611 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/python
  2. # -*- coding=utf-8 -*-
  3. # @Create Time: 2024-01-08 10:17:43
  4. # @Last Modified time: 2024-01-17 17:43:47
  5. from flask import Flask
  6. from config import config, Config
  7. def create_app(config_name):
  8. app = Flask(__name__)
  9. app.config.from_object(config[config_name])
  10. config[config_name].init_app(app)
  11. from . import models
  12. models.db.init_app(app)
  13. models.init_app(app)
  14. from .api import api as api_blueprint
  15. app.register_blueprint(api_blueprint, url_prefix='/api')
  16. from .main import main as main_blueprint
  17. app.register_blueprint(main_blueprint)
  18. return app