Skip to main content

higuma

Rust HTTPコアと、書き慣れたPython APIを組み合わせたWebフレームワークです。

日本語ドキュメント / English documentation

python -m pip install -U higuma

どんなフレームワークか

higumaは「アプリケーションはPythonで素直に書き、HTTPの実行基盤はRustに任せる」 ことを目的にしています。

  • routing、middleware、hooks、BlueprintはFlaskに着想を得たPython API
  • socket、route matching、file streaming、gzip、WebSocketはaxum / TokioベースのRustコア
  • MiniJinjaによるSSRと、辞書やlistをそのまま返せるJSON API
  • Python側の必須runtime dependencyはゼロ
  • CPython 3.10以降で利用できるABI3 wheel

higumaはFlaskのdrop-in replacementではありません。また、higuma自体をWSGI/ASGI serverへ渡すのではなく、組み込みのRust serverで実行します。既存のWSGI/ASGIアプリは higumaのroute配下へmountできます。

Quick start

app.pyを作成します。

from higuma import Higuma, request

app = Higuma(__name__)


@app.get("/")
def index():
    return {"message": "Hello from higuma"}


@app.post("/echo")
def echo():
    return {"received": request.json}


if __name__ == "__main__":
    app.run()

起動後、http://127.0.0.1:8000 を開きます。

python app.py

CLIからも起動できます。

higuma run app:app --host 127.0.0.1 --port 8000
higuma routes app:app
higuma run app:app --processes 4 --max-connections 1024

型付きAPIでは、標準のAnnotatedとdataclassだけで入力元、制約、dependency、出力を宣言できます。

from dataclasses import dataclass
from typing import Annotated

from higuma import Body, Depends, Higuma, QueryParam

app = Higuma(__name__)


@dataclass
class Item:
    name: str
    price: float


def page_size(limit: Annotated[int, QueryParam(ge=1, le=100)] = 20):
    return limit


@app.post("/items", response_model=Item, status_code=201)
def create_item(
    item: Annotated[Item, Body()],
    limit: Annotated[int, Depends(page_size)],
):
    return item

入力はruntimeで検証・変換され、不正時は構造化された422になります。schemaは同じ宣言から OpenAPI 3.1へ反映されます。

主な機能

分野 機能
HTTP typed input、dependency injection、path converter、自動HEAD/OPTIONS、async handler
Response response model、HTML、JSON、cookie、Range file、sync/async streaming、background task
Realtime SSE、text/binary/JSON WebSocket、Origin検証、認証preflight、bounded queue
SSR MiniJinja、compiled template cache、context processor
構成 Blueprint、class-based view、lifespan、WSGI/ASGI mount、startup/shutdown hook
API設計 OpenAPI 3.1、Swagger UI、dataclass/TypedDict/enum/UUID/date schema
Data dependency-free SQLite ORM、transaction、pagination、typed field
Auth signed cookie session、login/role/permission、OAuth 2.0 + PKCE
Security scrypt password、signed token、CSRF、CORS、rate limit、trusted host/proxy
Operations test client、CLI、multi-process supervisor、worker restart limit

完全な一覧と注意点は機能ガイドおよび APIリファレンスを参照してください。

Validationについて: Annotated[..., Body()]等のmarkerとresponse_modelはruntime検証を 有効にします。従来のrequest_body=やreturn annotation単独はschema metadataです。

対応範囲

  • Python: CPython 3.10以降(CIでは3.10〜3.14を検証)
  • OS: Windows x86-64、Linux x86-64 / ARM64、macOS x86-64 / Apple Silicon
  • Linux: manylinux wheelとmusllinux x86-64 wheelを配布
  • Database: 組み込みORMはSQLiteのみ
  • Protocol: 組み込みHTTP serverとWebSocket。TLSはreverse proxyで終端

wheelがないplatformではsource distributionからRust buildが必要です。公開済みの配布物は PyPIで確認できます。

Examples

examples/には、最小アプリだけでなく次の実行例があります。

  • routing、async handler、型付き入力、dependency injection、class-based view
  • response、cookie、file、multipart upload、streaming、SSE、background task
  • Blueprint、lifespan、WebSocket、WSGI/ASGI mount、OpenAPI
  • SQLite ORM、session authentication、role/permission、OAuth
  • security middleware、signed token、in-process testing
  • multi-process supervisor

必要な環境変数と実行コマンドはExamplesガイドに まとめています。

本番運用

higumaは活発に開発中です。本番採用前に、対象アプリケーションで負荷試験、障害試験、 security reviewを実施してください。

  • debug=Falseのまま運用する
  • Caddy、nginx、Cloudflare等でTLSを終端しHTTPSを強制する
  • 32バイト以上の推測不能なsecretをsecret managerから読み込む
  • TrustedHostMiddlewareと、正確なCORS / WebSocket Originを設定する
  • ProxyHeadersMiddlewareでは直接接続するproxyだけを信頼する
  • upload size、保存先、拡張子をアプリケーション側でも制限する
  • SQLite fileを定期backupし、multi-process時のwrite負荷を測定する
  • network timeout、request buffering、connection limitはreverse proxyでも設定する

詳しくはデプロイガイドと Security Policyを参照してください。

開発

python -m pip install -e ".[dev,docs]"
python -m pytest
python -m ruff check python tests examples
cargo test --locked --all-features
mkdocs build --strict

変更前にCONTRIBUTING.mdと、coding agent向けの SKILL.mdを確認してください。

ライセンス

MIT License

Metadata

Release files for higuma 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for higuma 0.4.0
File Size Uploaded
higuma-0.4.0.tar.gz 150.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for higuma 0.4.0
File
higuma-0.4.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
higuma-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
higuma-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
higuma-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
higuma-0.4.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
higuma-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 9.9 MB

Release files / higuma-0.4.0.tar.gz

Download URL higuma-0.4.0.tar.gz
Size 150.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7217dbe8062719345c1be978c0dae41faf31eaeda8ee9b0ea37c4918c49c63ca
BLAKE2b-256 checksum
How to use checksums
a17551d77fb320db98f8fbb44621ca7a0198858955f7a4197864aea3aa7fda10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / higuma-0.4.0-cp310-abi3-win_amd64.whl

Download URL higuma-0.4.0-cp310-abi3-win_amd64.whl
Size 1.5 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0f972f0959908235757c386a9c17e440a42a13b03a9bdb87e711dd8ec1814b8d
BLAKE2b-256 checksum
How to use checksums
2d8aa86d7de4b69b275fe1524be47ec31d7b01a4b71333283728fbdde8dd1f18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / higuma-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL higuma-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
97c56d9e4895a484aee2409fdb0b2cc911d01907cee1fe9954ac51186b67ee20
BLAKE2b-256 checksum
How to use checksums
f3043ea6ffbfd8552edf333ecd3ff1b9406cd18f7869006ef3db965744f7287e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / higuma-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL higuma-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a6f7059c429a94ece2526e1f408ab1a189e32fabbcf596b37164f8950f825177
BLAKE2b-256 checksum
How to use checksums
3e64104994220ae1fc1f6dc358444de9f973ca2d8b7561c85d2e0cdac3be1910
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / higuma-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL higuma-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3051934b0c1eb4caadc8aee8b91b99cfc30e848d6a9bc3b4ba4e1e2b23f1f661
BLAKE2b-256 checksum
How to use checksums
ea3d17dd73e37ab35a9081bd7c38e85615f9a963de6d0a1c7ab30e75d0e7be16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / higuma-0.4.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL higuma-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
67c06a1fad5e2265abb09050c8f8a8a9374a61699d173e8bc4bda82779c8358e
BLAKE2b-256 checksum
How to use checksums
093afb7906e9b18bfd4b2bdf09bec8e7d7961f4ba3a58e11d83d23a6a02ebe02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / higuma-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL higuma-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
31a908e37cdea71619acc7596db18a51d698a353d7e9abc462aa3579d1c20553
BLAKE2b-256 checksum
How to use checksums
9ffa83fe21ec6265cc475c1ff3d5491dd74e6df7f67ac08cdeb2320b09483609
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

7 release files

0.3.0

7 release files

0.2.0

7 release files

0.1.0

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page