# werkzeug.exceptions.MethodNotAllowed: 405 方法不被允许：请求的 URL 不允许该请求方法。

- **ID:** `python/flask-405-method-not-allowed`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

路由注册的 HTTP 方法与客户端发送的方法不一致（例如只注册了 GET 而客户端发送 POST/PUT/DELETE）。

## 版本兼容性

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

## 解决方案

1. **** (96% 成功率)
   ```
   @app.route('/submit', methods=['GET', 'POST'])
def submit(): ...
   ```
2. **** (90% 成功率)
   ```
   @app.post('/submit')
def submit_post(): ...
   ```

## 无效尝试

- **** — CSRF produces 400/403, not 405; the route method list is the actual cause. (85% 失败率)
- **** — Masks the real routing mismatch and breaks clients. (80% 失败率)
