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

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

## 根因

路由存在但未声明所使用的HTTP方法（例如对仅支持GET的路由发起POST）。

## 版本兼容性

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

## 解决方案

1. **** (96% 成功率)
   ```
   @app.route('/x', methods=['POST'])\ndef x(): ...
   ```
2. **** (94% 成功率)
   ```
   @app.get('/x')\n@app.post('/x')\ndef x(): ...
   ```

## 无效尝试

- **** — Does not enable POST; the 405 remains for POST requests. (80% 失败率)
- **** — Masks the real routing issue; clients still call the wrong method. (75% 失败率)
