mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2026-03-13 09:31:31 +08:00
Replace the uvicorn runner with granian (#1105)
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import os
|
import granian
|
||||||
|
|
||||||
import uvicorn
|
from backend.cli import CustomReloadFilter
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 为什么独立此启动文件:https://stackoverflow.com/questions/64003384
|
|
||||||
|
|
||||||
# DEBUG:
|
# DEBUG:
|
||||||
# 如果你喜欢在 IDE 中进行 DEBUG,可在 IDE 中直接右键启动此文件
|
# 如果你喜欢在 IDE 中进行 DEBUG,可在 IDE 中直接右键启动此文件
|
||||||
# 如果你喜欢通过 print 方式进行调试,建议使用 fba cli 方式启动服务
|
# 如果你喜欢通过 print 方式进行调试,建议使用 fba cli 方式启动服务
|
||||||
@@ -13,10 +11,11 @@ if __name__ == '__main__':
|
|||||||
# 如果你正在通过 python 命令启动此文件,请遵循以下事宜:
|
# 如果你正在通过 python 命令启动此文件,请遵循以下事宜:
|
||||||
# 1. 按照官方文档通过 uv 安装依赖
|
# 1. 按照官方文档通过 uv 安装依赖
|
||||||
# 2. 命令行空间位于 backend 目录下
|
# 2. 命令行空间位于 backend 目录下
|
||||||
uvicorn.run(
|
granian.Granian(
|
||||||
app='backend.main:app',
|
target='main:app',
|
||||||
host='127.0.0.1',
|
interface='asgi',
|
||||||
|
address='127.0.0.1',
|
||||||
port=8000,
|
port=8000,
|
||||||
reload=True,
|
reload=True,
|
||||||
reload_excludes=[os.path.abspath('../.venv')],
|
reload_filter=CustomReloadFilter,
|
||||||
)
|
).serve()
|
||||||
|
|||||||
Reference in New Issue
Block a user