From 1ad5482a22676ccb257e0f746f424c894685d03f Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Sun, 16 Jun 2024 14:09:14 +0800 Subject: [PATCH] Restore the main startup of fastapi service (#336) --- backend/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/main.py b/backend/main.py index 656778e0..ec8fd377 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,5 +1,18 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +from pathlib import Path + +import uvicorn + from backend.core.registrar import register_app app = register_app() + + +if __name__ == '__main__': + # 如果你喜欢在 IDE 中进行 DEBUG,main 启动方法会很有帮助 + # 如果你喜欢通过日志方式进行调试,建议使用 fastapi cli 方式启动服务 + try: + uvicorn.run(app=f'{Path(__file__).stem}:app', reload=True) + except Exception as e: + raise e