Files
docs-fastapi/docs/de/docs/advanced/wsgi.md
T
The Scheduler a42b1ff04e
Issue Manager / issue-manager (push) Has been cancelled
Build Docs / changes (push) Has been cancelled
Build Docs / langs (push) Has been cancelled
Build Docs / build-docs (push) Has been cancelled
Build Docs / docs-all-green (push) Has been cancelled
Conflict detector / main (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi) (push) Has been cancelled
Test Redistribute / test-redistribute (fastapi-slim) (push) Has been cancelled
Test Redistribute / test-redistribute-alls-green (push) Has been cancelled
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.13) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.13) (push) Has been cancelled
Test / test (pydantic-v2, 3.14) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
FastAPI People Contributors / job (push) Has been cancelled
FastAPI People Sponsors / job (push) Has been cancelled
Update Topic Repos / topic-repos (push) Has been cancelled
FastAPI People / job (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
Sync fastapi docs from b5ca1324 on 2025-12-07
2025-12-07 21:35:20 +00:00

1.4 KiB
Raw Blame History

WSGI inkludieren Flask, Django und andere

Sie können WSGI-Anwendungen mounten, wie Sie es in Unteranwendungen Mounts{.internal-link target=_blank}, Hinter einem Proxy{.internal-link target=_blank} gesehen haben.

Dazu können Sie die WSGIMiddleware verwenden und damit Ihre WSGI-Anwendung wrappen, zum Beispiel Flask, Django usw.

WSGIMiddleware verwenden

Sie müssen WSGIMiddleware importieren.

Wrappen Sie dann die WSGI-Anwendung (z. B. Flask) mit der Middleware.

Und dann mounten Sie das auf einem Pfad.

{* ../../docs_src/wsgi/tutorial001.py hl[2:3,3] *}

Es testen

Jetzt wird jeder Request unter dem Pfad /v1/ von der Flask-Anwendung verarbeitet.

Und der Rest wird von FastAPI gehandhabt.

Wenn Sie das ausführen und auf http://localhost:8000/v1/ gehen, sehen Sie die Response von Flask:

Hello, World from Flask!

Und wenn Sie auf http://localhost:8000/v2 gehen, sehen Sie die Response von FastAPI:

{
    "message": "Hello World"
}