urban-investment-research/debug.py

20 lines
642 B
Python

from fastapi.exceptions import RequestValidationError
from Config.uvicorn_log_config import uvicorn_log_config
from Utils.MiddlewareUtils import validation_exception_handler, exception_handler
from Utils.PrintUtils import hook_print_exception
from main import app
import uvicorn
from jurigged import watch
from Context.common import conf
# 中间件
app.exception_handler(Exception)(exception_handler)
app.exception_handler(RequestValidationError)(validation_exception_handler)
# debug环境
watch()
# 精简错误打印
hook_print_exception()
uvicorn.run(app, log_config=uvicorn_log_config, host="0.0.0.0", port=int(conf['app']['port']))