Files
test/run.py
T
2026-09-21 19:03:31 +08:00

28 lines
983 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""沃林学生管理系统 —— 启动入口。
在 PyCharm 里右键本文件 → Run 即可启动(或用命令行 `python run.py`)。
为什么入口要放在项目根,而不是直接跑 app/main.py:
Python 执行某个脚本时,会把**脚本所在目录**(不是工作目录)放到 sys.path[0]。
跑 app/main.py 时那个目录是 app/,于是它里面的
`from app.api import api_router` 就找不到 app 包,直接
`ModuleNotFoundError: No module named 'app'`。
本文件位于项目根,sys.path[0] 正好是项目根,包内绝对导入才成立。
启动后:
首页 http://127.0.0.1:8000
接口文档 http://127.0.0.1:8000/docs
管理员 admin / admin123
只读账号 viewer / viewer123
"""
import uvicorn
if __name__ == "__main__":
uvicorn.run(
"app.main:app",
host="127.0.0.1",
port=8000,
reload=False, # 想要改代码自动重启用 True(但调试时建议关掉)
)