claudegoodies
Command

flask-route

From davila7

Create Flask routes with proper structure and error handling.

Install

/flask-route

Facts

Status
Actively maintained
Last commit

Source preview

The instructions Claude Code reads when this command runs.

# Flask Route Generator

Create Flask routes with proper structure and error handling.

## Purpose

This command helps you quickly create Flask routes with validation, error handling, and best practices.

## Usage

```
/flask-route
```

## What this command does

1. **Creates route functions** with proper decorators
2. **Adds request validation** and error handling
3. **Includes JSON responses** and status codes
4. **Implements authentication** if needed
5. **Follows Flask conventions** and best practices

## Example Output

```python
# routes.py or app.py
from flask import Flask, request, jsonify, abort
from flask_sqlalchemy import SQLAlchemy
from werkzeug.exceptions import BadRequest

app = Flask(__name__)

@app.route('/users', methods=['GET'])
def get_users():
    """Get all users with optional pagination."""
    try:
        page = request.args.get('page', 1, type=int)
        per_page = request.args.get('per_page', 10, type=int)
        
        users = User.query.paginate(
            page=page, 
            per_page=per_page, 
            error_out=False
        )
        
        return jsonify({
            'users': [user.to_dict() for user in users.items],
            'total': users.total,
            'pages': users.pages,
            'current_page': page
        }), 200
        
    except Exception as e:
        return jsonify({'error': 'Failed to fetch users'}), 50
View full source on GitHub →

Other slash commands