urban-investment-research/debug.py

20 lines
631 B
Python
Raw Normal View History

2023-03-13 14:22:40 +08:00
from fastapi.exceptions import RequestValidationError
from Config.uvicorn_log_config import uvicorn_log_config
from Middleware.DebugMiddleware 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, port=int(conf['app']['port']))