flask
When to use this skill
Use this skill whenever the user wants to:
- Build Python web applications with Flask routing and templates
- Configure WSGI, blueprints, extensions, and deployment
- Integrate Flask-SQLAlchemy, Flask-Login, or other extensions
- Create REST APIs or serve server-rendered pages with Jinja2
How to use this skill
Workflow
- Create app — instantiate Flask and define routes
- Add templates — use Jinja2 for HTML rendering
- Organize with blueprints — split features into blueprint modules
- Configure and deploy — set environment config, deploy with Gunicorn
Quick Start Example
# app.py
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
app.config['SECRET_KEY'] = 'change-me-in-production'
@app.route('/')
def index():
return render_template('index.html', title='Home')
@app.route('/api/items', methods=['GET', 'POST'])
def items():
if request.method == 'POST':
data = request.get_json()
# Process and save item
return jsonify({'status': 'created', 'item': data}), 201
return jsonify({'items': []})
if __name__ == '__main__':
app.run(debug=True)
Application Factory Pattern
# __init__.py
from flask import Flask
def create_app(config_name='default'):
app = Flask(__name__)
app.config.from_object(config[config_name])
# Initialize extensions
db.init_app(app)
login_manager.init_app(app)
# Register blueprints
from .auth import auth_bp
app.register_blueprint(auth_bp, url_prefix='/auth')
from .main import main_bp
app.register_blueprint(main_bp)
return app
# Development
flask --app app run --debug
# Production
gunicorn -w 4 -b 0.0.0.0:8000 "app:create_app()"
Blueprint Example
# auth/routes.py
from flask import Blueprint, render_template, redirect, url_for
auth_bp = Blueprint('auth', __name__, template_folder='templates')
@auth_bp.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
# Authenticate user
return redirect(url_for('main.index'))
return render_template('auth/login.html')
Best Practices
- Use the application factory pattern with blueprints for modularity
- Keep sensitive configuration out of source code — use environment variables
- Deploy with Gunicorn or uWSGI behind a reverse proxy (nginx)
- Enable CSRF protection with Flask-WTF; set security headers
- Use
flask shellfor interactive debugging with app context
Reference
- Official documentation: https://flask.palletsprojects.com/
Keywords
flask, Python web, routing, templates, Jinja2, blueprints, WSGI, REST API, Gunicorn
More from partme-ai/full-stack-skills
element-plus-vue3
Provides comprehensive guidance for Element Plus Vue 3 component library including installation, components, themes, internationalization, and API reference. Use when the user asks about Element Plus for Vue 3, needs to build Vue 3 applications with Element Plus, or customize component styles.
63electron
Build cross-platform desktop applications with Electron, covering main/renderer process architecture, IPC communication, BrowserWindow management, menus, tray icons, packaging, and security best practices. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps.
51uniapp-project
Provides per-component and per-API examples with cross-platform compatibility details for uni-app, covering built-in components, uni-ui components, and APIs (network, storage, device, UI, navigation, media). Use when the user needs official uni-app components or APIs, wants per-component examples with doc links, or needs platform compatibility checks.
40ascii-cli-logo-banner
Entry point for ASCII CLI banners that routes to the Python built-in font skill or figlet.js/FIGfont skill. Use when the user wants a startup banner, ASCII logo, terminal welcome screen, or CLI branding for a service.
38ascii-terminal-animation-pack
Plan and generate terminal ASCII animations/screensaver-style output (FPS, refresh rules, loop policy, low-flicker guidance), with a static poster frame and an optional local demo script.
34ascii-image-to-ascii
“Convert an image into ASCII art (readable + detail variants, width/charset controls, optional ANSI), for terminal previews and plain-text image substitutes.”
34