You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
989 B
39 lines
989 B
import os
|
|
from logging.config import dictConfig
|
|
|
|
from flask_api import FlaskAPI
|
|
|
|
from . import command
|
|
from . import container
|
|
|
|
|
|
def create_app() -> FlaskAPI:
|
|
app = FlaskAPI(__name__)
|
|
app.register_blueprint(command.bp)
|
|
|
|
dictConfig(
|
|
{
|
|
"version": 1,
|
|
"formatters": {
|
|
"default": {
|
|
"format": "[%(asctime)s] %(levelname)s in %(module)s: %(message)s",
|
|
},
|
|
},
|
|
"handlers": {
|
|
"wsgi": {
|
|
"class": "logging.StreamHandler",
|
|
"stream": "ext://flask.logging.wsgi_errors_stream",
|
|
"formatter": "default",
|
|
},
|
|
},
|
|
"root": {"level": "DEBUG", "handlers": ["wsgi"]},
|
|
},
|
|
)
|
|
|
|
container.init_app(app)
|
|
|
|
if os.environ.get("WERKZEUG_RUN_MAIN") != "true":
|
|
# prevent from be called twice in debug mode
|
|
command.start_backgroup_process()
|
|
|
|
return app
|
|
|