メインコンテンツまでスキップ
パフォーマンス。生産性。プロフェッショナル。

Lihil

The Official website of python webframework lihil

はじめるGitHub
openai
from lihil import Lihil, Route, Stream
from openai import OpenAI
from openai.types.chat import ChatCompletionChunk as Chunk
from openai.types.chat import ChatCompletionUserMessageParam as MessageIn
gpt = Route("/gpt", deps=[OpenAI])
def message_encoder(chunk: Chunk) -> bytes:
if not chunk.choices:
return b""
return chunk.choices[0].delta.content.encode() or b""
@gpt.sub("/messages").post(encoder=message_encoder)
async def add_new_message(
client: OpenAPI, question: MessageIn, model: str
) -> Stream[Chunk]:
async for chunk in client.responses.create(
messages=[question], model=model, stream=True
):
yield chunk

50%-100%

他のASGIフレームワークより高速で、大規模アプリケーションに最適。 ベンチマーク

100%

テストカバレッジと厳密な型安全性

> 45K

RPS(CPUスレッドあたり)


Get Started in Seconds

Lihil is designed for simplicity without sacrificing power. Install with pip and start building your next Python web application.

$|
インストール

数分でREST APIを作成

app.py
from lihil import Lihil, HTTPException, Struct, Route, Param, Annotated, Empty
class TodoItem(Struct):
id: int
title: str
completed: bool = False
todo = Route("/todos", deps=[TodoRepo])
@todo.get
async def get_todos(todo_repo: TodoRepo, n: Annotated[int, Param(lt=100)]):
return await todo_repo.list_todos()
@todo.post
async def create_todo(item: TodoItem, todo_repo: TodoRepo) -> Annotated[Empty, 201]:
await todo_repo.add(item)
if __name__ == "__main__":
lhl = Lihil(todo)
lhl.run(__file__)

なぜLihilを選ぶのか?

モダンなアプリケーション向けに構築された、クリーンで強力なPython Webフレームワーク。
パラメータ解析と検証

msgspecを使用してパス、クエリ、ヘッダー、ボディからのリクエストデータを自動的に解析・検証。Pydanticより12倍高速で25倍メモリ効率が良い。

強力な依存性注入

型ヒントに基づいて依存関係を注入。ファクトリー、非同期、スコープ、シングルトンをサポート - すべて超高速。

WebSocket

クリーンで型安全なAPIでWebSocket接続を処理。内蔵のWebSocketテストクライアントで簡単にテスト可能。

OpenAPIとエラードキュメント

OpenAPIドキュメントと問題詳細を自動生成。カスタム例外は明確なAPIレスポンスに変換される。

認証と認可

JWTとOAuth2の内蔵サポート。認証オブジェクトは型安全でシリアライズ可能。

メッセージシステム

プロセス内外でイベントを効率的に発行・処理する内蔵イベントシステム。

優れたテスト性

エンドポイント、ルート、ミドルウェア用の内蔵テストクライアント - 追加設定不要。

メモリ効率

最小限のメモリ使用量に最適化。GCオーバーヘッドが削減され、負荷下でのサービス安定性が向上。

AI対応

AIを念頭に設計。SSE、MCP、リモートハンドラーの内蔵サポートが近日公開予定。


Join the Community

Lihil is backed by a growing community of Python developers. Get support, contribute, and help shape the future of fast Python web development.

GitHubDiscordContribute
Latest Release

Loading...

Release Notes

素晴らしいものを作る準備はできていますか?

Lihilを使用して高速で堅牢、スケーラブルなWebアプリケーションを構築する成長中の開発者コミュニティに参加しませんか。

今すぐ始める