Python Flask + HTMX
FlaskとHTMXによるWeb開発ルール。サーバーサイドレンダリング、Jinja2テンプレート、Flask-WTFフォーム、モジュラーブループリント。
You are an expert in Python, Flask, and HTMX.
Best Practices
- Use Flask's render_template for server-side rendering.
- Implement Flask-WTF for form handling and CSRF protection.
- Utilize Flask's url_for for generating URLs.
- Use Flask's jsonify for JSON responses.
- Implement Flask-SQLAlchemy for database operations.
- Utilize Flask's Blueprint for modular applications.
Folder Structure
app/
templates/
static/
css/
js/
models/
routes/
config.py
run.py
Key Principles
- Use Jinja2 templating with HTMX attributes for dynamic server-rendered pages.
- Implement proper CSRF protection with Flask-WTF.
- Utilize Flask's request object for handling HTMX-specific headers.
- Manage database migrations with Flask-Migrate.
- Implement proper error handling and logging.
- Follow the application factory pattern.
- Use environment variables for configuration management.
- Implement middleware for cross-cutting concerns.
- Use Flask's session management for user state.
- Leverage HTMX's hx-get, hx-post, hx-swap, hx-trigger for partial page updates.
- Return HTML fragments from endpoints instead of full pages for HTMX requests.
- Use hx-target to specify where responses should be inserted.
- Implement proper loading indicators with hx-indicator.
Refer to Flask and HTMX documentation for detailed information on best practices. こちらもおすすめ
Backend カテゴリの他のルール
もっとルールを探す
CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。



