2024-04-15 04:02:47 +03:00
|
|
|
from dishka.integrations.flask import setup_dishka
|
2024-04-13 04:41:30 +03:00
|
|
|
from flask import Flask
|
2024-04-16 01:03:02 +03:00
|
|
|
|
|
|
|
from flask_demo_api.error_handlers import register_errors
|
|
|
|
from flask_demo_api.ioc import create_container
|
|
|
|
from flask_demo_api.routers.key import key_bp
|
2024-04-13 04:41:30 +03:00
|
|
|
|
|
|
|
|
|
|
|
def app_factory() -> Flask:
|
|
|
|
app = Flask(__name__)
|
2024-04-16 01:03:02 +03:00
|
|
|
register_errors(app)
|
2024-04-15 02:16:07 +03:00
|
|
|
app.register_blueprint(key_bp)
|
2024-04-13 04:41:30 +03:00
|
|
|
return app
|
2024-04-15 02:16:07 +03:00
|
|
|
|
|
|
|
|
2024-04-16 01:03:02 +03:00
|
|
|
def run_app():
|
2024-04-15 02:16:07 +03:00
|
|
|
app = app_factory()
|
2024-04-16 01:03:02 +03:00
|
|
|
|
2024-04-15 04:02:47 +03:00
|
|
|
container = create_container()
|
|
|
|
setup_dishka(container=container, app=app, auto_inject=True)
|
2024-04-16 04:58:20 +03:00
|
|
|
app.run(host="0.0.0.0", debug=True)
|
2024-04-16 01:03:02 +03:00
|
|
|
container.close()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
run_app()
|