python
runtime_error
ai_generated
true
运行时错误:未配置应用程序
RuntimeError: No application configured
ID: python/starlette-runtime-error-no-app
80%修复率
85%置信度
0证据数
2024-03-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
未创建Starlette应用程序实例或未将其传递给ASGI服务器。
English
Starlette application instance is not created or not passed to the ASGI server.
解决方案
-
90% 成功率 Define a Starlette app instance and pass it to uvicorn.
from starlette.applications import Starlette app = Starlette() # Then run: uvicorn main:app
-
85% 成功率 Ensure the server command references the correct module and app variable.
uvicorn mymodule:app --reload
无效尝试
常见但无效的做法:
-
Trying to run the server without defining the app variable.
80% 失败
The server expects an ASGI application object; without it, it fails.
-
Using a wrong file name in the server command.
70% 失败
The server cannot find the app if the module path is incorrect.