# 运行时错误：未配置应用程序

- **ID:** `python/starlette-runtime-error-no-app`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

未创建Starlette应用程序实例或未将其传递给ASGI服务器。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Define a Starlette app instance and pass it to uvicorn.** (90% 成功率)
   ```
   from starlette.applications import Starlette
app = Starlette()
# Then run: uvicorn main:app
   ```
2. **Ensure the server command references the correct module and app variable.** (85% 成功率)
   ```
   uvicorn mymodule:app --reload
   ```

## 无效尝试

- **Trying to run the server without defining the app variable.** — The server expects an ASGI application object; without it, it fails. (80% 失败率)
- **Using a wrong file name in the server command.** — The server cannot find the app if the module path is incorrect. (70% 失败率)
