# Werkzeug路由构建错误：无法为端点 'index' 构建URL

- **ID:** `python/flask-url-build-error-endpoint`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

端点名称拼写错误或路由不存在。

## 版本兼容性

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

## 解决方案

1. **Check the defined routes and ensure the endpoint name is correct.** (90% 成功率)
   ```
   print(app.url_map)  # List all routes and endpoints
   ```
2. **Use the correct endpoint name in url_for.** (95% 成功率)
   ```
   url_for('home')  # Replace 'home' with the actual endpoint
   ```

## 无效尝试

- **Adding a random URL parameter to the url_for function.** — The endpoint still does not exist; parameters only work for existing routes. (80% 失败率)
- **Using the function name instead of the endpoint name incorrectly.** — If the endpoint is explicitly set, the function name may not match. (60% 失败率)
