flask
БесплатноБез исполняемых скриптовНе проверенFlask - Lightweight Python web framework for microservices, REST APIs, and flexible web applications with extensive extension ecosystem
от bobmatnyc★ 160 звёзд на GitHubОб этом скилле
Flask - Lightweight Python Web Framework
Overview
Flask is a micro-framework for Python web development, designed for building microservices, REST APIs, and flexible web applications. Its minimalist core and extensive extension ecosystem make it ideal for projects requiring lightweight architecture, rapid development, and full control over components.
Key Features:
- Micro-framework philosophy (minimal core, extensible)
- Flask-RESTful for API development
- Blueprints for modular application structure
- SQLAlchemy integration via Flask-SQLAlchemy
- Jinja2 templating engine
- Built-in development server with auto-reload
- Werkzeug WSGI toolkit foundation
- Large extension ecosystem (Flask-Login, Flask-JWT, Flask-CORS)
- Production deployment with Gunicorn/uWSGI
Installation:
# Basic Flask
pip install flask
# Flask with common extensions
pip install flask flask-restful flask-sqlalchemy flask-login flask-cors
# With database support
pip install flask flask-sqlalchemy psycopg2-binary # PostgreSQL
# Full microservices stack
pip install flask flask-restful marshmallow flask-jwt-extended redis
Basic Application Patterns
1. Minimal Flask App
# app.py
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/')
def hello():
return jsonify({"message": "Hello, World!"})
@app.route('/api/users/<int:user_id>')
def get_user(user_id):
return jsonify({"id": user_id, "name": f"User {user_id}"})
@app.route('/api/users', methods=['POST'])
def create_user():
data = request.get_json()
return jsonify({"id": 123, **data}), 201
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)
Run:
# Development server
python app.py
# Or using flask CLI
export FLASK_APP=app.py
export FLASK_ENV=development
flask run
# Custom port
flask run --port 8000 --host 0.0.0.0
2. Application Factory Pattern
Recommended for production and testing:
# app/__init__.py
from flask import Flask
from app.config import Config
from app.extensions import db, migrate, jwt
def create_app(config_class=Config):
"""Application factory pattern."""
app = Flask(__name__)
app.config.from_object(config_class)
# Initialize extensions
db.init_app(app)
migrate.init_app(app, db)
jwt.init_app(app)
# Register blueprints
from app.routes import api_bp, auth_bp
app.register_blueprint(api_bp, url_prefix='/api')
app.register_blueprint(auth_bp, url_prefix='/auth')
return app
# app/extensions.py
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_jwt_extended import JWTManager
db = SQLAlchemy()
migrate = Migrate()
jwt = JWTManager()
# app/config.py
import os
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-secret-key'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///app.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False
JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY') or 'jwt-secret'
class DevelopmentConfig(Config):
DEBUG = True
TESTING = False
class ProductionConfig(Config):
DEBUG = False
TESTING = False
# run.py
from app import create_app
app = create_app()
if __name__ == '__main__':
app.run()
Run:
export FLASK_APP=run.py
flask run
3. Request and Response Handling
from flask import Flask, request, jsonify, make_response, abort
app = Flask(__name__)
@app.route('/api/data', methods=['GET', 'POST'])
def handle_data():
# GET request
if request.method == 'GET':
# Query parameters
page = request.args.get('page', 1, type=int)
limit = request.args.get('limit', 10, type=int)
return jsonify({
"page": page,
"limit": limit,
"data": [...]
})
# POST request
if request.method == 'POST':
# JSON body
data = request.get_json()
# Validation
if not data or 'name' not in data:
abort(400, description="Missing required field: name")
# Custom response with headers
response = make_response(jsonify({"id": 1, **data}), 201)
response.headers['X-Custom-Header'] = 'value'
return response
# Error handling
@app.errorhandler(404)
def not_found(error):
return jsonify({"error": "Resource not found"}), 404
@app.errorhandler(400)
def bad_request(error):
return jsonify({"error": str(error.description)}), 400
Blueprints - Modular Applications
Blueprint Structure
app/
├── __init__.py # Application factory
├── extensions.py # Extension instances
├── config.py # Configuration
├── models/
│ ├── __init__.py
│ ├── user.py
│ └── product.py
├── routes/
│ ├── __init__.py
│ ├── auth.py # Authentication routes
│ ├── users.py # User management routes
│ └── products.py # Product routes
└── services/
├── __init__.py
├──
Установить flask в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл flask?
Flask - Lightweight Python web framework for microservices, REST APIs, and flexible web applications with extensive extension ecosystem
Как установить скилл flask?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл flask запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic