0.10+の非同期高速経路・async DB・Signals・Redis共有状態・運用監視を追加しています。
API、HTML、リアルタイム通信を、書き慣れたPythonのdecoratorで。 higumaという名前は日本のヒグマに由来します。
0.9.0の新機能
親子Blueprint・CLI・async test、SQLAlchemy/Redis連携、 大容量入力を追加しました。性能測定で条件と限界を公開します。
0.8.0以降のサーバー選択
app.asgi_app/app.wsgi_appで外部サーバーにも載せられます。
ASGI HTTP・lifespan・WebSocketと、WSGI HTTPに対応します。
同期互換worker・stream・proxy・resourceの制約はサーバーインターフェース、
検証方法はテストガイドを参照してください。
from higuma import Higuma
app = Higuma(__name__)
@app.get("/")
def index():
return {"message": "Hello from higuma"}
app.run()
設計¶
higumaは、Flaskに着想を得たdecorator APIと、axum / Tokioによる組み込みHTTP serverを組み合わせます。application logicはPythonで記述し、socket、route matching、 file streaming、gzip、WebSocketをRust coreが処理します。
higumaはFlaskのdrop-in replacementではありません。外部ASGI/WSGIサーバーへは
明示的なasgi_app/wsgi_appを渡します。逆方向の、他アプリのHTTP mountも提供します。
主な機能¶
Annotated型付き入力、dependency injection、response model、構造化422- typed converter、自動HEAD/OPTIONS、sync / async handler、class-based view
- Blueprint、middleware、request / response hook、lifespan
- MiniJinja SSR、context processor、compiled template cache
- sync / async streaming、SSE、background task、range / ETag file、automatic gzip
- text / binary / JSON WebSocket、same-origin検証、認証preflight
- multipart uploadと安全なfilename helper
- OpenAPI 3.1 / Swagger UI、dataclass・TypedDict・enum等のschema
- transactionとpaginationを備えたSQLite ORM
- signed session、login、role / permission、OAuth 2.0 + PKCE
- Flask風application context、
g、session proxy、flash、URL生成 - password、token、CSRF、CORS、rate limit、trusted host / proxy
- in-process test client、CLI、multi-process supervisor
- CSR/SPA history fallback、複数static root、Vite manifest(0.6.0以降)
OpenAPIと入力検証
Annotated[..., Body()]等はruntimeで入力を検証・Python objectへ変換し、同じ宣言から
OpenAPIを生成します。response_modelは出力も検証します。従来のrequest_body=と
return annotation単独はschema metadataです。
対応範囲¶
- CPython 3.10以降
- Windows、Linux、macOS向けABI3 wheel
- 組み込みORMはSQLite専用
- TLS終端、buffering、network-level limitはreverse proxyを推奨
次に読む¶
- はじめる
- 機能ガイド
- CSR・フロントエンド
- 機能対応表
- Flask互換性
- ASGI・WSGI・組み込みサーバー
- テストとrequest context
- 認証とセキュリティ
- Examples
- APIリファレンス
- デプロイ
- ロゴ・ブランド素材
Warning
higumaは活発に開発中です。本番採用前に、対象applicationで負荷試験、障害試験、 security reviewを行ってください。
