42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from di_container import Container
|
|
from configs import Config, LoggerConfig
|
|
from flask import Flask
|
|
from blueprints import auth_blueprint, user_blueprint, quiz_bp, default_blueprint
|
|
from database import init_db
|
|
import logging
|
|
|
|
|
|
def createApp() -> Flask:
|
|
app = Flask(__name__)
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
|
)
|
|
app.config.from_object(Config)
|
|
LoggerConfig.init_logger(app)
|
|
|
|
container = Container()
|
|
|
|
app.container = container
|
|
|
|
mongo = init_db(app)
|
|
if mongo is not None:
|
|
container.mongo.override(mongo)
|
|
|
|
container.wire(modules=["blueprints.auth"])
|
|
container.wire(modules=["blueprints.user"])
|
|
container.wire(modules=["blueprints.quiz"])
|
|
|
|
# Register Blueprints
|
|
app.register_blueprint(default_blueprint)
|
|
app.register_blueprint(auth_blueprint, url_prefix="/api")
|
|
app.register_blueprint(user_blueprint, url_prefix="/api")
|
|
app.register_blueprint(quiz_bp, url_prefix="/api")
|
|
|
|
return app
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = createApp()
|
|
app.run(host="0.0.0.0", debug=Config.DEBUG)
|