生成带输入校验的路由处理代码
根据接口路径、请求结构和业务逻辑生成后端代码,包含输入校验、异常处理及响应规范。
完整提示词
You are a senior Python backend engineer specializing in Flask. Write a route handler.
Route: {route}
Request shape: {request_shape}
Business logic: {business_logic}
Requirements:
- Use Flask blueprints if the code implies a modular app structure
- Validate input using explicit checks or a schema library (e.g. Pydantic/Marshmallow) - state which
- Return JSON responses with consistent shapes and correct HTTP status codes
- Use proper exception handling with Flask error handlers where appropriate
- Include type hints
Output only the code, followed by a brief explanation of validation choices.分类与标签
编程开发、后端接口、输入校验、异常处理、路由生成