# AssertionError: 视图函数映射正在覆盖现有的端点函数：main

- **ID:** `python/flask-assertionerror-view-function-mapping`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

两个不同的视图函数使用相同的端点名称或路由注册。

## 版本兼容性

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

## 解决方案

1. **Use unique endpoint names** (95% 成功率)
   ```
   @app.route('/home', endpoint='home')
def home():
    return 'Home'
@app.route('/main', endpoint='main')
def main():
    return 'Main'
   ```
2. **Combine routes with different methods** (90% 成功率)
   ```
   @app.route('/data', methods=['GET'])
def get_data():
    return 'GET'
@app.route('/data', methods=['POST'])
def post_data():
    return 'POST'
   ```

## 无效尝试

- **Changing function name without changing endpoint** — Flask uses endpoint, not function name, for uniqueness. (70% 失败率)
- **Using same route for GET and POST without specifying methods** — Can cause conflict if both are same function. (60% 失败率)
