<summary>About the command <code>fastapi dev main.py</code>...</summary>
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a>.
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>.
By default, `fastapi dev` will start with auto-reload enabled for local development.
@ -472,7 +472,7 @@ Used by Starlette:
Used by FastAPI:
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* `fastapi-cli[standard]` - to provide the `fastapi` command.
* This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to <ahref="https://fastapicloud.com"class="external-link"target="_blank">FastAPI Cloud</a>.
@ -154,7 +154,7 @@ In der technischen ASGI-Spezifikation ist dies Teil des <a href="https://asgi.re
/// info | Info
Weitere Informationen zu Starlettes `lifespan`-Handlern finden Sie in <ahref="https://www.starlette.io/lifespan/"class="external-link"target="_blank">Starlettes Lifespan-Dokumentation</a>.
Weitere Informationen zu Starlettes `lifespan`-Handlern finden Sie in <ahref="https://www.starlette.dev/lifespan/"class="external-link"target="_blank">Starlettes Lifespan-Dokumentation</a>.
Einschließlich, wie man Lifespan-Zustand handhabt, der in anderen Bereichen Ihres Codes verwendet werden kann.
Um mehr über weitere verfügbare Middlewares herauszufinden, besuchen Sie <ahref="https://www.starlette.io/middleware/"class="external-link"target="_blank">Starlettes Middleware-Dokumentation</a> und die <ahref="https://github.com/florimondmanca/awesome-asgi"class="external-link"target="_blank">ASGI Awesome List</a>.
Um mehr über weitere verfügbare Middlewares herauszufinden, besuchen Sie <ahref="https://www.starlette.dev/middleware/"class="external-link"target="_blank">Starlettes Middleware-Dokumentation</a> und die <ahref="https://github.com/florimondmanca/awesome-asgi"class="external-link"target="_blank">ASGI Awesome List</a>.
@ -48,4 +48,4 @@ Und da die `Response` häufig zum Setzen von Headern und Cookies verwendet wird,
///
Um alle verfügbaren Parameter und Optionen anzuzeigen, sehen Sie sich deren <ahref="https://www.starlette.io/responses/#set-cookie"class="external-link"target="_blank">Dokumentation in Starlette</a> an.
Um alle verfügbaren Parameter und Optionen anzuzeigen, sehen Sie sich deren <ahref="https://www.starlette.dev/responses/#set-cookie"class="external-link"target="_blank">Dokumentation in Starlette</a> an.
@ -38,4 +38,4 @@ Und da die `Response` häufig zum Setzen von Headern und Cookies verwendet wird,
Beachten Sie, dass benutzerdefinierte proprietäre Header <ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"class="external-link"target="_blank">mittels des Präfix `X-`</a> hinzugefügt werden können.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen können soll, müssen Sie diese zu Ihrer CORS-Konfiguration hinzufügen (weitere Informationen finden Sie unter [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), unter Verwendung des Parameters `expose_headers`, dokumentiert in <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">Starlettes CORS-Dokumentation</a>.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen können soll, müssen Sie diese zu Ihrer CORS-Konfiguration hinzufügen (weitere Informationen finden Sie unter [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), unter Verwendung des Parameters `expose_headers`, dokumentiert in <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">Starlettes CORS-Dokumentation</a>.
@ -123,4 +123,4 @@ Und da Sie `StaticFiles` verwenden, wird diese CSS-Datei automatisch von Ihrer *
## Mehr Details { #more-details }
Weitere Informationen, einschließlich, wie man Templates testet, finden Sie in <ahref="https://www.starlette.io/templates/"class="external-link"target="_blank">Starlettes Dokumentation zu Templates</a>.
Weitere Informationen, einschließlich, wie man Templates testet, finden Sie in <ahref="https://www.starlette.dev/templates/"class="external-link"target="_blank">Starlettes Dokumentation zu Templates</a>.
Sie können mehr Details unter [„Lifespan in Tests ausführen in der offiziellen Starlette-Dokumentation.“](https://www.starlette.io/lifespan/#running-lifespan-in-tests) nachlesen.
Sie können mehr Details unter [„Lifespan in Tests ausführen in der offiziellen Starlette-Dokumentation.“](https://www.starlette.dev/lifespan/#running-lifespan-in-tests) nachlesen.
Für die deprecateten Events <abbrtitle="Hochfahren">`startup`</abbr> und <abbrtitle="Herunterfahren">`shutdown`</abbr> können Sie den `TestClient` wie folgt verwenden:
@ -8,6 +8,6 @@ Dazu verwenden Sie den `TestClient` in einer `with`-Anweisung, eine Verbindung z
/// note | Hinweis
Weitere Informationen finden Sie in Starlettes Dokumentation zum <ahref="https://www.starlette.io/testclient/#testing-websocket-sessions"class="external-link"target="_blank">Testen von WebSockets</a>.
Weitere Informationen finden Sie in Starlettes Dokumentation zum <ahref="https://www.starlette.dev/testclient/#testing-websocket-sessions"class="external-link"target="_blank">Testen von WebSockets</a>.
@ -15,7 +15,7 @@ Es gibt jedoch Situationen, in denen Sie möglicherweise direkt auf das `Request
## Details zum `Request`-Objekt { #details-about-the-request-object }
Da **FastAPI** unter der Haube eigentlich **Starlette** ist, mit einer Ebene von mehreren Tools darüber, können Sie Starlettes <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">`Request`</a>-Objekt direkt verwenden, wenn Sie es benötigen.
Da **FastAPI** unter der Haube eigentlich **Starlette** ist, mit einer Ebene von mehreren Tools darüber, können Sie Starlettes <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">`Request`</a>-Objekt direkt verwenden, wenn Sie es benötigen.
Das bedeutet allerdings auch, dass, wenn Sie Daten direkt vom `Request`-Objekt nehmen (z. B. dessen Body lesen), diese von FastAPI nicht validiert, konvertiert oder dokumentiert werden (mit OpenAPI, für die automatische API-Benutzeroberfläche).
@ -45,7 +45,7 @@ Auf die gleiche Weise können Sie wie gewohnt jeden anderen Parameter deklariere
Weitere Details zum <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">`Request`-Objekt finden Sie in der offiziellen Starlette-Dokumentation</a>.
Weitere Details zum <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">`Request`-Objekt finden Sie in der offiziellen Starlette-Dokumentation</a>.
Starlette ist ein leichtgewichtiges <abbrtitle="Der neue Standard für die Erstellung asynchroner Python-Webanwendungen">ASGI</abbr>-Framework/Toolkit, welches sich ideal für die Erstellung hochperformanter asynchroner Dienste eignet.
@ -462,7 +462,7 @@ Alles, was Sie also mit Starlette machen können, können Sie direkt mit **FastA
@ -52,7 +52,7 @@ Das Wichtigste, was Sie benötigen, um eine **FastAPI**-Anwendung (oder eine and
Es gibt mehrere Alternativen, einschließlich:
* <ahref="https://www.uvicorn.org/"class="external-link"target="_blank">Uvicorn</a>: ein hochperformanter ASGI-Server.
* <ahref="https://www.uvicorn.dev/"class="external-link"target="_blank">Uvicorn</a>: ein hochperformanter ASGI-Server.
* <ahref="https://hypercorn.readthedocs.io/"class="external-link"target="_blank">Hypercorn</a>: ein ASGI-Server, der unter anderem kompatibel mit HTTP/2 und Trio ist.
* <ahref="https://github.com/django/daphne"class="external-link"target="_blank">Daphne</a>: der für Django Channels entwickelte ASGI-Server.
* <ahref="https://github.com/emmett-framework/granian"class="external-link"target="_blank">Granian</a>: Ein Rust HTTP-Server für Python-Anwendungen.
@ -52,7 +52,7 @@ FastAPI CLI nimmt den Pfad zu Ihrem Python-Programm (z. B. `main.py`), erkennt a
Für die Produktion würden Sie stattdessen `fastapi run` verwenden. 🚀
Intern verwendet das **FastAPI CLI**<ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a>, einen leistungsstarken, produktionsreifen, ASGI-Server. 😎
Intern verwendet das **FastAPI CLI**<ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>, einen leistungsstarken, produktionsreifen, ASGI-Server. 😎
@ -159,7 +159,7 @@ Jede Integration wurde so entworfen, dass sie so einfach zu nutzen ist (mit Abh
## Starlette Merkmale { #starlette-features }
**FastAPI** ist vollkommen kompatibel (und basiert auf) <ahref="https://www.starlette.io/"class="external-link"target="_blank"><strong>Starlette</strong></a>. Das bedeutet, wenn Sie eigenen Starlette Quellcode haben, funktioniert der.
**FastAPI** ist vollkommen kompatibel (und basiert auf) <ahref="https://www.starlette.dev/"class="external-link"target="_blank"><strong>Starlette</strong></a>. Das bedeutet, wenn Sie eigenen Starlette Quellcode haben, funktioniert der.
`FastAPI` ist tatsächlich eine Unterklasse von `Starlette`. Wenn Sie also bereits Starlette kennen oder benutzen, das meiste funktioniert genau so.
@ -58,7 +58,7 @@ Nachdem ich mehrere Alternativen getestet hatte, entschied ich, dass ich <a href
Dann habe ich zu dessen Code beigetragen, um es vollständig mit JSON Schema kompatibel zu machen, und so verschiedene Möglichkeiten zum Definieren von einschränkenden Deklarationen (Constraints) zu unterstützen, und die Editorunterstützung (Typprüfungen, Codevervollständigung) zu verbessern, basierend auf den Tests in mehreren Editoren.
Während der Entwicklung habe ich auch zu <ahref="https://www.starlette.io/"class="external-link"target="_blank">**Starlette**</a> beigetragen, der anderen Schlüsselanforderung.
Während der Entwicklung habe ich auch zu <ahref="https://www.starlette.dev/"class="external-link"target="_blank">**Starlette**</a> beigetragen, der anderen Schlüsselanforderung.
@ -66,7 +66,7 @@ Das `scope`-`dict` und die `receive`-Funktion sind beide Teil der ASGI-Spezifika
Und diese beiden Dinge, `scope` und `receive`, werden benötigt, um eine neue `Request`-Instanz zu erstellen.
Um mehr über den `Request` zu erfahren, schauen Sie sich <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">Starlettes Dokumentation zu Requests</a> an.
Um mehr über den `Request` zu erfahren, schauen Sie sich <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">Starlettes Dokumentation zu Requests</a> an.
<summary>Was der Befehl <code>fastapi dev main.py</code> macht ...</summary>
Der Befehl `fastapi dev` liest Ihre `main.py`-Datei, erkennt die **FastAPI**-App darin und startet einen Server mit <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a>.
Der Befehl `fastapi dev` liest Ihre `main.py`-Datei, erkennt die **FastAPI**-App darin und startet einen Server mit <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>.
Standardmäßig wird `fastapi dev` mit aktiviertem Auto-Reload für die lokale Entwicklung gestartet.
@ -470,7 +470,7 @@ Verwendet von Starlette:
Verwendet von FastAPI:
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> – für den Server, der Ihre Anwendung lädt und bereitstellt. Dies umfasst `uvicorn[standard]`, das einige Abhängigkeiten (z. B. `uvloop`) beinhaltet, die für eine Bereitstellung mit hoher Performanz benötigt werden.
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> – für den Server, der Ihre Anwendung lädt und bereitstellt. Dies umfasst `uvicorn[standard]`, das einige Abhängigkeiten (z. B. `uvloop`) beinhaltet, die für eine Bereitstellung mit hoher Performanz benötigt werden.
* `fastapi-cli[standard]` – um den `fastapi`-Befehl bereitzustellen.
* Dies beinhaltet `fastapi-cloud-cli`, das es Ihnen ermöglicht, Ihre FastAPI-Anwendung auf <ahref="https://fastapicloud.com"class="external-link"target="_blank">FastAPI Cloud</a> bereitzustellen.
@ -63,7 +63,7 @@ Und dann schreibt ein weiterer Hintergrundtask, der in der *Pfadoperation-Funkti
## Technische Details { #technical-details }
Die Klasse `BackgroundTasks` stammt direkt von <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">`starlette.background`</a>.
Die Klasse `BackgroundTasks` stammt direkt von <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">`starlette.background`</a>.
Sie wird direkt in FastAPI importiert/inkludiert, sodass Sie sie von `fastapi` importieren können und vermeiden, versehentlich das alternative `BackgroundTask` (ohne das `s` am Ende) von `starlette.background` zu importieren.
@ -71,7 +71,7 @@ Indem Sie nur `BackgroundTasks` (und nicht `BackgroundTask`) verwenden, ist es d
Es ist immer noch möglich, `BackgroundTask` allein in FastAPI zu verwenden, aber Sie müssen das Objekt in Ihrem Code erstellen und eine Starlette-`Response` zurückgeben, die es enthält.
Weitere Details finden Sie in <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">Starlettes offizieller Dokumentation für Hintergrundtasks</a>.
Weitere Details finden Sie in <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">Starlettes offizieller Dokumentation für Hintergrundtasks</a>.
Sie können benutzerdefinierte <abbrtitle="Ausnahmebehandler: Funktion, die sich um die Bearbeitung einer Exception kümmert">Exceptionhandler</abbr> mit <ahref="https://www.starlette.io/exceptions/"class="external-link"target="_blank">den gleichen Exception-Werkzeugen von Starlette</a> hinzufügen.
Sie können benutzerdefinierte <abbrtitle="Ausnahmebehandler: Funktion, die sich um die Bearbeitung einer Exception kümmert">Exceptionhandler</abbr> mit <ahref="https://www.starlette.dev/exceptions/"class="external-link"target="_blank">den gleichen Exception-Werkzeugen von Starlette</a> hinzufügen.
Angenommen, Sie haben eine benutzerdefinierte Exception `UnicornException`, die Sie (oder eine Bibliothek, die Sie verwenden) `raise`n könnten.
Beachten Sie, dass benutzerdefinierte proprietäre Header hinzugefügt werden können <ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"class="external-link"target="_blank">unter Verwendung des `X-`-Präfixes</a>.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen soll, müssen Sie sie zu Ihrer CORS-Konfiguration ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) hinzufügen, indem Sie den Parameter `expose_headers` verwenden, der in der <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">Starlettes CORS-Dokumentation</a> dokumentiert ist.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen soll, müssen Sie sie zu Ihrer CORS-Konfiguration ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) hinzufügen, indem Sie den Parameter `expose_headers` verwenden, der in der <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">Starlettes CORS-Dokumentation</a> dokumentiert ist.
@ -37,4 +37,4 @@ Alle diese Parameter können anders als „`static`“ lauten, passen Sie sie an
## Weitere Informationen { #more-info }
Weitere Details und Optionen finden Sie in der <ahref="https://www.starlette.io/staticfiles/"class="external-link"target="_blank">Dokumentation von Starlette zu statischen Dateien</a>.
Weitere Details und Optionen finden Sie in der <ahref="https://www.starlette.dev/staticfiles/"class="external-link"target="_blank">Dokumentation von Starlette zu statischen Dateien</a>.
Dank <ahref="https://www.starlette.io/testclient/"class="external-link"target="_blank">Starlette</a> ist das Testen von **FastAPI**-Anwendungen einfach und macht Spaß.
Dank <ahref="https://www.starlette.dev/testclient/"class="external-link"target="_blank">Starlette</a> ist das Testen von **FastAPI**-Anwendungen einfach und macht Spaß.
Es basiert auf <ahref="https://www.python-httpx.org"class="external-link"target="_blank">HTTPX</a>, welches wiederum auf der Grundlage von Requests konzipiert wurde, es ist also sehr vertraut und intuitiv.
@ -154,7 +154,7 @@ Underneath, in the ASGI technical specification, this is part of the <a href="ht
/// info
You can read more about the Starlette `lifespan` handlers in <ahref="https://www.starlette.io/lifespan/"class="external-link"target="_blank">Starlette's Lifespan' docs</a>.
You can read more about the Starlette `lifespan` handlers in <ahref="https://www.starlette.dev/lifespan/"class="external-link"target="_blank">Starlette's Lifespan' docs</a>.
Including how to handle lifespan state that can be used in other areas of your code.
To see other available middlewares check <ahref="https://www.starlette.io/middleware/"class="external-link"target="_blank">Starlette's Middleware docs</a> and the <ahref="https://github.com/florimondmanca/awesome-asgi"class="external-link"target="_blank">ASGI Awesome List</a>.
To see other available middlewares check <ahref="https://www.starlette.dev/middleware/"class="external-link"target="_blank">Starlette's Middleware docs</a> and the <ahref="https://github.com/florimondmanca/awesome-asgi"class="external-link"target="_blank">ASGI Awesome List</a>.
@ -48,4 +48,4 @@ And as the `Response` can be used frequently to set headers and cookies, **FastA
///
To see all the available parameters and options, check the <ahref="https://www.starlette.io/responses/#set-cookie"class="external-link"target="_blank">documentation in Starlette</a>.
To see all the available parameters and options, check the <ahref="https://www.starlette.dev/responses/#set-cookie"class="external-link"target="_blank">documentation in Starlette</a>.
@ -38,4 +38,4 @@ And as the `Response` can be used frequently to set headers and cookies, **FastA
Keep in mind that custom proprietary headers can be added <ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"class="external-link"target="_blank">using the `X-` prefix</a>.
But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), using the parameter `expose_headers` documented in <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">Starlette's CORS docs</a>.
But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), using the parameter `expose_headers` documented in <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">Starlette's CORS docs</a>.
@ -123,4 +123,4 @@ And because you are using `StaticFiles`, that CSS file would be served automatic
## More details { #more-details }
For more details, including how to test templates, check <ahref="https://www.starlette.io/templates/"class="external-link"target="_blank">Starlette's docs on templates</a>.
For more details, including how to test templates, check <ahref="https://www.starlette.dev/templates/"class="external-link"target="_blank">Starlette's docs on templates</a>.
You can read more details about the ["Running lifespan in tests in the official Starlette documentation site."](https://www.starlette.io/lifespan/#running-lifespan-in-tests)
You can read more details about the ["Running lifespan in tests in the official Starlette documentation site."](https://www.starlette.dev/lifespan/#running-lifespan-in-tests)
For the deprecated `startup` and `shutdown` events, you can use the `TestClient` as follows:
@ -8,6 +8,6 @@ For this, you use the `TestClient` in a `with` statement, connecting to the WebS
/// note
For more details, check Starlette's documentation for <ahref="https://www.starlette.io/testclient/#testing-websocket-sessions"class="external-link"target="_blank">testing WebSockets</a>.
For more details, check Starlette's documentation for <ahref="https://www.starlette.dev/testclient/#testing-websocket-sessions"class="external-link"target="_blank">testing WebSockets</a>.
@ -15,7 +15,7 @@ But there are situations where you might need to access the `Request` object dir
## Details about the `Request` object { #details-about-the-request-object }
As **FastAPI** is actually **Starlette** underneath, with a layer of several tools on top, you can use Starlette's <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">`Request`</a> object directly when you need to.
As **FastAPI** is actually **Starlette** underneath, with a layer of several tools on top, you can use Starlette's <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">`Request`</a> object directly when you need to.
It would also mean that if you get data from the `Request` object directly (for example, read the body) it won't be validated, converted or documented (with OpenAPI, for the automatic API user interface) by FastAPI.
@ -45,7 +45,7 @@ The same way, you can declare any other parameter as normally, and additionally,
You can read more details about the <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">`Request` object in the official Starlette documentation site</a>.
You can read more details about the <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">`Request` object in the official Starlette documentation site</a>.
Starlette is a lightweight <abbrtitle="The new standard for building asynchronous Python web applications">ASGI</abbr> framework/toolkit, which is ideal for building high-performance asyncio services.
@ -462,7 +462,7 @@ So, anything that you can do with Starlette, you can do it directly with **FastA
@ -52,7 +52,7 @@ The main thing you need to run a **FastAPI** application (or any other ASGI appl
There are several alternatives, including:
* <ahref="https://www.uvicorn.org/"class="external-link"target="_blank">Uvicorn</a>: a high performance ASGI server.
* <ahref="https://www.uvicorn.dev/"class="external-link"target="_blank">Uvicorn</a>: a high performance ASGI server.
* <ahref="https://hypercorn.readthedocs.io/"class="external-link"target="_blank">Hypercorn</a>: an ASGI server compatible with HTTP/2 and Trio among other features.
* <ahref="https://github.com/django/daphne"class="external-link"target="_blank">Daphne</a>: the ASGI server built for Django Channels.
* <ahref="https://github.com/emmett-framework/granian"class="external-link"target="_blank">Granian</a>: A Rust HTTP server for Python applications.
@ -159,7 +159,7 @@ Any integration is designed to be so simple to use (with dependencies) that you
## Starlette features { #starlette-features }
**FastAPI** is fully compatible with (and based on) <ahref="https://www.starlette.io/"class="external-link"target="_blank"><strong>Starlette</strong></a>. So, any additional Starlette code you have, will also work.
**FastAPI** is fully compatible with (and based on) <ahref="https://www.starlette.dev/"class="external-link"target="_blank"><strong>Starlette</strong></a>. So, any additional Starlette code you have, will also work.
`FastAPI` is actually a sub-class of `Starlette`. So, if you already know or use Starlette, most of the functionality will work the same way.
@ -58,7 +58,7 @@ After testing several alternatives, I decided that I was going to use <a href="h
Then I contributed to it, to make it fully compliant with JSON Schema, to support different ways to define constraint declarations, and to improve editor support (type checks, autocompletion) based on the tests in several editors.
During the development, I also contributed to <ahref="https://www.starlette.io/"class="external-link"target="_blank">**Starlette**</a>, the other key requirement.
During the development, I also contributed to <ahref="https://www.starlette.dev/"class="external-link"target="_blank">**Starlette**</a>, the other key requirement.
@ -66,7 +66,7 @@ The `scope` `dict` and `receive` function are both part of the ASGI specificatio
And those two things, `scope` and `receive`, are what is needed to create a new `Request` instance.
To learn more about the `Request` check <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">Starlette's docs about Requests</a>.
To learn more about the `Request` check <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">Starlette's docs about Requests</a>.
<summary>About the command <code>fastapi dev main.py</code>...</summary>
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a>.
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>.
By default, `fastapi dev` will start with auto-reload enabled for local development.
@ -470,7 +470,7 @@ Used by Starlette:
Used by FastAPI:
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* `fastapi-cli[standard]` - to provide the `fastapi` command.
* This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to <ahref="https://fastapicloud.com"class="external-link"target="_blank">FastAPI Cloud</a>.
@ -5526,7 +5526,7 @@ Note: all the previous parameters are still there, so it's still possible to dec
* Upgrade the compatible version of Starlette to `0.12.0`.
* This includes support for ASGI 3 (the latest version of the standard).
* It's now possible to use [Starlette's `StreamingResponse`](https://www.starlette.io/responses/#streamingresponse) with iterators, like [file-like](https://docs.python.org/3/glossary.html#term-file-like-object) objects (as those returned by `open()`).
* It's now possible to use [Starlette's `StreamingResponse`](https://www.starlette.dev/responses/#streamingresponse) with iterators, like [file-like](https://docs.python.org/3/glossary.html#term-file-like-object) objects (as those returned by `open()`).
* It's now possible to use the low level utility `iterate_in_threadpool` from `starlette.concurrency` (for advanced scenarios).
@ -63,7 +63,7 @@ And then another background task generated at the *path operation function* will
## Technical Details { #technical-details }
The class `BackgroundTasks` comes directly from <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">`starlette.background`</a>.
The class `BackgroundTasks` comes directly from <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">`starlette.background`</a>.
It is imported/included directly into FastAPI so that you can import it from `fastapi` and avoid accidentally importing the alternative `BackgroundTask` (without the `s` at the end) from `starlette.background`.
@ -71,7 +71,7 @@ By only using `BackgroundTasks` (and not `BackgroundTask`), it's then possible t
It's still possible to use `BackgroundTask` alone in FastAPI, but you have to create the object in your code and return a Starlette `Response` including it.
You can see more details in <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">Starlette's official docs for Background Tasks</a>.
You can see more details in <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">Starlette's official docs for Background Tasks</a>.
You can add custom exception handlers with <ahref="https://www.starlette.io/exceptions/"class="external-link"target="_blank">the same exception utilities from Starlette</a>.
You can add custom exception handlers with <ahref="https://www.starlette.dev/exceptions/"class="external-link"target="_blank">the same exception utilities from Starlette</a>.
Let's say you have a custom exception `UnicornException` that you (or a library you use) might `raise`.
@ -37,7 +37,7 @@ The middleware function receives:
Keep in mind that custom proprietary headers can be added <ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"class="external-link"target="_blank">using the `X-` prefix</a>.
But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) using the parameter `expose_headers` documented in <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">Starlette's CORS docs</a>.
But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) using the parameter `expose_headers` documented in <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">Starlette's CORS docs</a>.
@ -37,4 +37,4 @@ All these parameters can be different than "`static`", adjust them with the need
## More info { #more-info }
For more details and options check <ahref="https://www.starlette.io/staticfiles/"class="external-link"target="_blank">Starlette's docs about Static Files</a>.
For more details and options check <ahref="https://www.starlette.dev/staticfiles/"class="external-link"target="_blank">Starlette's docs about Static Files</a>.
Thanks to <ahref="https://www.starlette.io/testclient/"class="external-link"target="_blank">Starlette</a>, testing **FastAPI** applications is easy and enjoyable.
Thanks to <ahref="https://www.starlette.dev/testclient/"class="external-link"target="_blank">Starlette</a>, testing **FastAPI** applications is easy and enjoyable.
It is based on <ahref="https://www.python-httpx.org"class="external-link"target="_blank">HTTPX</a>, which in turn is designed based on Requests, so it's very familiar and intuitive.
@ -154,7 +154,7 @@ Por debajo, en la especificación técnica ASGI, esto es parte del <a href="http
/// info | Información
Puedes leer más sobre los manejadores `lifespan` de Starlette en <ahref="https://www.starlette.io/lifespan/"class="external-link"target="_blank">la documentación de `Lifespan` de Starlette</a>.
Puedes leer más sobre los manejadores `lifespan` de Starlette en <ahref="https://www.starlette.dev/lifespan/"class="external-link"target="_blank">la documentación de `Lifespan` de Starlette</a>.
Incluyendo cómo manejar el estado de lifespan que puede ser usado en otras áreas de tu código.
* <ahref="https://github.com/encode/uvicorn/blob/master/uvicorn/middleware/proxy_headers.py"class="external-link"target="_blank">`ProxyHeadersMiddleware` de Uvicorn</a>
Para ver otros middlewares disponibles, revisa <ahref="https://www.starlette.io/middleware/"class="external-link"target="_blank">la documentación de Middleware de Starlette</a> y la <ahref="https://github.com/florimondmanca/awesome-asgi"class="external-link"target="_blank">Lista ASGI Awesome</a>.
Para ver otros middlewares disponibles, revisa <ahref="https://www.starlette.dev/middleware/"class="external-link"target="_blank">la documentación de Middleware de Starlette</a> y la <ahref="https://github.com/florimondmanca/awesome-asgi"class="external-link"target="_blank">Lista ASGI Awesome</a>.
@ -48,4 +48,4 @@ Y como el `Response` se puede usar frecuentemente para establecer headers y cook
///
Para ver todos los parámetros y opciones disponibles, revisa la <ahref="https://www.starlette.io/responses/#set-cookie"class="external-link"target="_blank">documentación en Starlette</a>.
Para ver todos los parámetros y opciones disponibles, revisa la <ahref="https://www.starlette.dev/responses/#set-cookie"class="external-link"target="_blank">documentación en Starlette</a>.
@ -38,4 +38,4 @@ Y como el `Response` se puede usar frecuentemente para establecer headers y cook
Ten en cuenta que los headers propietarios personalizados se pueden agregar <ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"class="external-link"target="_blank">usando el prefijo 'X-'</a>.
Pero si tienes headers personalizados que quieres que un cliente en un navegador pueda ver, necesitas agregarlos a tus configuraciones de CORS (leer más en [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), usando el parámetro `expose_headers` documentado en <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">la documentación CORS de Starlette</a>.
Pero si tienes headers personalizados que quieres que un cliente en un navegador pueda ver, necesitas agregarlos a tus configuraciones de CORS (leer más en [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), usando el parámetro `expose_headers` documentado en <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">la documentación CORS de Starlette</a>.
@ -123,4 +123,4 @@ Y porque estás usando `StaticFiles`, ese archivo CSS sería servido automática
## Más detalles
Para más detalles, incluyendo cómo testear plantillas, revisa <ahref="https://www.starlette.io/templates/"class="external-link"target="_blank">la documentación de Starlette sobre plantillas</a>.
Para más detalles, incluyendo cómo testear plantillas, revisa <ahref="https://www.starlette.dev/templates/"class="external-link"target="_blank">la documentación de Starlette sobre plantillas</a>.
@ -8,6 +8,6 @@ Para esto, usas el `TestClient` en un statement `with`, conectándote al WebSock
/// note | Nota
Para más detalles, revisa la documentación de Starlette sobre <ahref="https://www.starlette.io/testclient/#testing-websocket-sessions"class="external-link"target="_blank">probando sesiones WebSocket</a>.
Para más detalles, revisa la documentación de Starlette sobre <ahref="https://www.starlette.dev/testclient/#testing-websocket-sessions"class="external-link"target="_blank">probando sesiones WebSocket</a>.
@ -15,7 +15,7 @@ Pero hay situaciones donde podrías necesitar acceder al objeto `Request` direct
## Detalles sobre el objeto `Request`
Como **FastAPI** es en realidad **Starlette** por debajo, con una capa de varias herramientas encima, puedes usar el objeto <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">`Request`</a> de Starlette directamente cuando lo necesites.
Como **FastAPI** es en realidad **Starlette** por debajo, con una capa de varias herramientas encima, puedes usar el objeto <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">`Request`</a> de Starlette directamente cuando lo necesites.
También significa que si obtienes datos del objeto `Request` directamente (por ejemplo, leyendo el cuerpo) no serán validados, convertidos o documentados (con OpenAPI, para la interfaz automática de usuario de la API) por FastAPI.
@ -45,7 +45,7 @@ De la misma manera, puedes declarar cualquier otro parámetro como normalmente,
## Documentación de `Request`
Puedes leer más detalles sobre el <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">objeto `Request` en el sitio de documentación oficial de Starlette</a>.
Puedes leer más detalles sobre el <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">objeto `Request` en el sitio de documentación oficial de Starlette</a>.
Starlette es un framework/toolkit <abbrtitle="El nuevo estándar para construir aplicaciones web asíncronas en Python">ASGI</abbr> liviano, ideal para construir servicios asyncio de alto rendimiento.
@ -462,7 +462,7 @@ Por lo tanto, cualquier cosa que puedas hacer con Starlette, puedes hacerlo dire
@ -64,7 +64,7 @@ Lo principal que necesitas para ejecutar una aplicación **FastAPI** (o cualquie
Hay varias alternativas, incluyendo:
* <ahref="https://www.uvicorn.org/"class="external-link"target="_blank">Uvicorn</a>: un servidor ASGI de alto rendimiento.
* <ahref="https://www.uvicorn.dev/"class="external-link"target="_blank">Uvicorn</a>: un servidor ASGI de alto rendimiento.
* <ahref="https://hypercorn.readthedocs.io/"class="external-link"target="_blank">Hypercorn</a>: un servidor ASGI compatible con HTTP/2 y Trio entre otras funcionalidades.
* <ahref="https://github.com/django/daphne"class="external-link"target="_blank">Daphne</a>: el servidor ASGI construido para Django Channels.
* <ahref="https://github.com/emmett-framework/granian"class="external-link"target="_blank">Granian</a>: Un servidor HTTP Rust para aplicaciones en Python.
@ -52,7 +52,7 @@ FastAPI CLI toma el path de tu programa Python (por ejemplo, `main.py`), detecta
Para producción usarías `fastapi run` en su lugar. 🚀
Internamente, **FastAPI CLI** usa <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a>, un servidor ASGI de alto rendimiento y listo para producción. 😎
Internamente, **FastAPI CLI** usa <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>, un servidor ASGI de alto rendimiento y listo para producción. 😎
@ -159,7 +159,7 @@ Cualquier integración está diseñada para ser tan simple de usar (con dependen
## Funcionalidades de Starlette
**FastAPI** es totalmente compatible con (y está basado en) <ahref="https://www.starlette.io/"class="external-link"target="_blank"><strong>Starlette</strong></a>. Así que, cualquier código adicional de Starlette que tengas, también funcionará.
**FastAPI** es totalmente compatible con (y está basado en) <ahref="https://www.starlette.dev/"class="external-link"target="_blank"><strong>Starlette</strong></a>. Así que, cualquier código adicional de Starlette que tengas, también funcionará.
`FastAPI` es en realidad una subclase de `Starlette`. Así que, si ya conoces o usas Starlette, la mayoría de las funcionalidades funcionarán de la misma manera.
@ -58,7 +58,7 @@ Después de probar varias alternativas, decidí que iba a usar <a href="https://
Luego contribuí a este, para hacerlo totalmente compatible con JSON Schema, para soportar diferentes maneras de definir declaraciones de restricciones, y para mejorar el soporte de los editores (chequeo de tipos, autocompletado) basado en las pruebas en varios editores.
Durante el desarrollo, también contribuí a <ahref="https://www.starlette.io/"class="external-link"target="_blank">**Starlette**</a>, el otro requisito clave.
Durante el desarrollo, también contribuí a <ahref="https://www.starlette.dev/"class="external-link"target="_blank">**Starlette**</a>, el otro requisito clave.
@ -66,7 +66,7 @@ El `dict` `scope` y la función `receive` son ambos parte de la especificación
Y esas dos cosas, `scope` y `receive`, son lo que se necesita para crear una nueva *Request instance*.
Para aprender más sobre el `Request`, revisa <ahref="https://www.starlette.io/requests/"class="external-link"target="_blank">la documentación de Starlette sobre Requests</a>.
Para aprender más sobre el `Request`, revisa <ahref="https://www.starlette.dev/requests/"class="external-link"target="_blank">la documentación de Starlette sobre Requests</a>.
<summary>Acerca del comando <code>fastapi dev main.py</code>...</summary>
El comando `fastapi dev` lee tu archivo `main.py`, detecta la app **FastAPI** en él y arranca un servidor usando <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a>.
El comando `fastapi dev` lee tu archivo `main.py`, detecta la app **FastAPI** en él y arranca un servidor usando <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>.
Por defecto, `fastapi dev` comenzará con auto-recarga habilitada para el desarrollo local.
@ -470,7 +470,7 @@ Usadas por Starlette:
Usadas por FastAPI / Starlette:
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - para el servidor que carga y sirve tu aplicación. Esto incluye `uvicorn[standard]`, que incluye algunas dependencias (por ejemplo, `uvloop`) necesarias para servir con alto rendimiento.
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> - para el servidor que carga y sirve tu aplicación. Esto incluye `uvicorn[standard]`, que incluye algunas dependencias (por ejemplo, `uvloop`) necesarias para servir con alto rendimiento.
* `fastapi-cli` - para proporcionar el comando `fastapi`.
@ -61,7 +61,7 @@ Y luego otra tarea en segundo plano generada en la *path operation function* esc
## Detalles Técnicos
La clase `BackgroundTasks` proviene directamente de <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">`starlette.background`</a>.
La clase `BackgroundTasks` proviene directamente de <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">`starlette.background`</a>.
Se importa/incluye directamente en FastAPI para que puedas importarla desde `fastapi` y evitar importar accidentalmente la alternativa `BackgroundTask` (sin la `s` al final) de `starlette.background`.
@ -69,7 +69,7 @@ Al usar solo `BackgroundTasks` (y no `BackgroundTask`), es posible usarla como u
Todavía es posible usar `BackgroundTask` solo en FastAPI, pero debes crear el objeto en tu código y devolver una `Response` de Starlette incluyéndolo.
Puedes ver más detalles en <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">la documentación oficial de Starlette sobre Background Tasks</a>.
Puedes ver más detalles en <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">la documentación oficial de Starlette sobre Background Tasks</a>.
@ -81,7 +81,7 @@ Pero en caso de que los necesites para un escenario avanzado, puedes agregar hea
## Instalar manejadores de excepciones personalizados
Puedes agregar manejadores de excepciones personalizados con <ahref="https://www.starlette.io/exceptions/"class="external-link"target="_blank">las mismas utilidades de excepciones de Starlette</a>.
Puedes agregar manejadores de excepciones personalizados con <ahref="https://www.starlette.dev/exceptions/"class="external-link"target="_blank">las mismas utilidades de excepciones de Starlette</a>.
Supongamos que tienes una excepción personalizada `UnicornException` que tú (o un paquete que usas) podría lanzar.
Ten en cuenta que los custom proprietary headers se pueden añadir <ahref="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"class="external-link"target="_blank">usando el prefijo 'X-'</a>.
Pero si tienes custom headers que deseas que un cliente en un navegador pueda ver, necesitas añadirlos a tus configuraciones de CORS ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) usando el parámetro `expose_headers` documentado en <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">la documentación de CORS de Starlette</a>.
Pero si tienes custom headers que deseas que un cliente en un navegador pueda ver, necesitas añadirlos a tus configuraciones de CORS ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) usando el parámetro `expose_headers` documentado en <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">la documentación de CORS de Starlette</a>.
@ -37,4 +37,4 @@ Todos estos parámetros pueden ser diferentes a "`static`", ajústalos según la
## Más info
Para más detalles y opciones revisa <ahref="https://www.starlette.io/staticfiles/"class="external-link"target="_blank">la documentación de Starlette sobre Archivos Estáticos</a>.
Para más detalles y opciones revisa <ahref="https://www.starlette.dev/staticfiles/"class="external-link"target="_blank">la documentación de Starlette sobre Archivos Estáticos</a>.
Gracias a <ahref="https://www.starlette.io/testclient/"class="external-link"target="_blank">Starlette</a>, escribir pruebas para aplicaciones de **FastAPI** es fácil y agradable.
Gracias a <ahref="https://www.starlette.dev/testclient/"class="external-link"target="_blank">Starlette</a>, escribir pruebas para aplicaciones de **FastAPI** es fácil y agradable.
Está basado en <ahref="https://www.python-httpx.org"class="external-link"target="_blank">HTTPX</a>, que a su vez está diseñado basado en Requests, por lo que es muy familiar e intuitivo.
@ -167,7 +167,7 @@ FastAPI شامل یک سیستم <abbr title='همچنین به عنوان "comp
## ویژگی های Starlette
**FastAPI** کاملا (و براساس) با <ahref="https://www.starlette.io/"class="external-link"target="_blank"><strong>Starlette</strong></a> سازگار است. بنابراین، هرکد اضافی Starlette که دارید، نیز کار خواهد کرد.
**FastAPI** کاملا (و براساس) با <ahref="https://www.starlette.dev/"class="external-link"target="_blank"><strong>Starlette</strong></a> سازگار است. بنابراین، هرکد اضافی Starlette که دارید، نیز کار خواهد کرد.
`FastAPI` در واقع یک زیرکلاس از `Starlette` است. بنابراین اگر از قبل Starlette را میشناسید یا با آن کار کرده اید، بیشتر قابلیت ها به همین روش کار خواهد کرد.
@ -116,7 +116,7 @@ FastAPI یک وب فریمورک مدرن و سریع (با کارایی با
FastAPI مبتنی بر ابزارهای قدرتمند زیر است:
* فریمورک <ahref="https://www.starlette.io/"class="external-link"target="_blank">Starlette</a> برای بخش وب.
* فریمورک <ahref="https://www.starlette.dev/"class="external-link"target="_blank">Starlette</a> برای بخش وب.
* کتابخانه <ahref="https://docs.pydantic.dev/"class="external-link"target="_blank">Pydantic</a> برای بخش داده.
## نصب
@ -131,7 +131,7 @@ $ pip install fastapi
</div>
نصب یک سرور پروداکشن نظیر <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> یا <ahref="https://github.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a> نیز جزء نیازمندیهاست.
نصب یک سرور پروداکشن نظیر <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a> یا <ahref="https://github.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a> نیز جزء نیازمندیهاست.
<divclass="termy">
@ -456,7 +456,7 @@ item: Item
استفاده شده توسط FastAPI / Starlette:
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - برای سرور اجرا کننده برنامه وب.
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> - برای سرور اجرا کننده برنامه وب.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - در صورتی که بخواهید از `ORJSONResponse` استفاده کنید.
* <ahref="https://github.com/esnme/ultrajson"target="_blank"><code>ujson</code></a> - در صورتی که بخواهید از `UJSONResponse` استفاده کنید.
/// نکته | به خاطر داشته باشید که هدرهای اختصاصی سفارشی را می توان با استفاده از پیشوند "X-" اضافه کرد.
اما اگر هدرهای سفارشی دارید که میخواهید مرورگر کاربر بتواند آنها را ببیند، باید آنها را با استفاده از پارامتر `expose_headers` که در مستندات <ahref="https://www.starlette.io/middleware/#corsmiddleware"class="external-link"target="_blank">CORS از Starlette</a> توضیح داده شده است، به پیکربندی CORS خود اضافه کنید.
اما اگر هدرهای سفارشی دارید که میخواهید مرورگر کاربر بتواند آنها را ببیند، باید آنها را با استفاده از پارامتر `expose_headers` که در مستندات <ahref="https://www.starlette.dev/middleware/#corsmiddleware"class="external-link"target="_blank">CORS از Starlette</a> توضیح داده شده است، به پیکربندی CORS خود اضافه کنید.
Starlette est un framework/toolkit léger <abbrtitle="Le nouveau standard pour construire des applications web asynchrones en Python">ASGI</abbr>, qui est idéal pour construire des services asyncio performants.
@ -498,7 +498,7 @@ Ainsi, tout ce que vous pouvez faire avec Starlette, vous pouvez le faire direct
@ -4,7 +4,7 @@ La principale chose dont vous avez besoin pour exécuter une application **FastA
Il existe 3 principales alternatives :
* <ahref="https://www.uvicorn.org/"class="external-link"target="_blank">Uvicorn</a> : un serveur ASGI haute performance.
* <ahref="https://www.uvicorn.dev/"class="external-link"target="_blank">Uvicorn</a> : un serveur ASGI haute performance.
* <ahref="https://hypercorn.readthedocs.io/"class="external-link"target="_blank">Hypercorn</a> : un serveur
ASGI compatible avec HTTP/2 et Trio entre autres fonctionnalités.
* <ahref="https://github.com/django/daphne"class="external-link"target="_blank">Daphne</a> : le serveur ASGI
@ -27,7 +27,7 @@ Vous pouvez installer un serveur compatible ASGI avec :
//// tab | Uvicorn
* <ahref="https://www.uvicorn.org/"class="external-link"target="_blank">Uvicorn</a>, un serveur ASGI rapide comme l'éclair, basé sur uvloop et httptools.
* <ahref="https://www.uvicorn.dev/"class="external-link"target="_blank">Uvicorn</a>, un serveur ASGI rapide comme l'éclair, basé sur uvloop et httptools.
@ -158,7 +158,7 @@ Tout intégration est conçue pour être si simple à utiliser (avec des dépend
## Fonctionnalités de Starlette
**FastAPI** est complètement compatible (et basé sur) <ahref="https://www.starlette.io/"class="external-link"target="_blank"><strong>Starlette</strong></a>. Le code utilisant Starlette que vous ajouterez fonctionnera donc aussi.
**FastAPI** est complètement compatible (et basé sur) <ahref="https://www.starlette.dev/"class="external-link"target="_blank"><strong>Starlette</strong></a>. Le code utilisant Starlette que vous ajouterez fonctionnera donc aussi.
En fait, `FastAPI` est un sous composant de `Starlette`. Donc, si vous savez déjà comment utiliser Starlette, la plupart des fonctionnalités fonctionneront de la même manière.
@ -58,7 +58,7 @@ Après avoir testé plusieurs alternatives, j'ai décidé que j'allais utiliser
J'y ai ensuite contribué, pour le rendre entièrement compatible avec JSON Schema, pour supporter différentes manières de définir les déclarations de contraintes, et pour améliorer le support des éditeurs (vérifications de type, autocomplétion) sur la base des tests effectués dans plusieurs éditeurs.
Pendant le développement, j'ai également contribué à <ahref="https://www.starlette.io/"class="external-link"target="_blank">**Starlette**</a>, l'autre exigence clé.
Pendant le développement, j'ai également contribué à <ahref="https://www.starlette.dev/"class="external-link"target="_blank">**Starlette**</a>, l'autre exigence clé.
@ -123,7 +123,7 @@ Si vous souhaitez construire une application <abbr title="Command Line Interface
FastAPI repose sur les épaules de géants :
* <ahref="https://www.starlette.io/"class="external-link"target="_blank">Starlette</a> pour les parties web.
* <ahref="https://www.starlette.dev/"class="external-link"target="_blank">Starlette</a> pour les parties web.
* <ahref="https://docs.pydantic.dev/"class="external-link"target="_blank">Pydantic</a> pour les parties données.
## Installation
@ -138,7 +138,7 @@ $ pip install fastapi
</div>
Vous aurez également besoin d'un serveur ASGI pour la production tel que <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> ou <ahref="https://github.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
Vous aurez également besoin d'un serveur ASGI pour la production tel que <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a> ou <ahref="https://github.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -461,7 +461,7 @@ Utilisées par Starlette :
Utilisées par FastAPI / Starlette :
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - Pour le serveur qui charge et sert votre application.
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> - Pour le serveur qui charge et sert votre application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Obligatoire si vous voulez utiliser `ORJSONResponse`.
* <ahref="https://github.com/esnme/ultrajson"target="_blank"><code>ujson</code></a> - Obligatoire si vous souhaitez utiliser `UJSONResponse`.
@ -61,7 +61,7 @@ Et ensuite une autre tâche d'arrière-plan (générée dans les paramètres de
## Détails techniques
La classe `BackgroundTasks` provient directement de <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">`starlette.background`</a>.
La classe `BackgroundTasks` provient directement de <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">`starlette.background`</a>.
Elle est importée/incluse directement dans **FastAPI** pour que vous puissiez l'importer depuis `fastapi` et éviter d'importer accidentellement `BackgroundTask` (sans `s` à la fin) depuis `starlette.background`.
@ -69,7 +69,7 @@ En utilisant seulement `BackgroundTasks` (et non `BackgroundTask`), il est possi
Il est tout de même possible d'utiliser `BackgroundTask` seul dans **FastAPI**, mais dans ce cas il faut créer l'objet dans le code et renvoyer une `Response` Starlette l'incluant.
Plus de détails sont disponibles dans <ahref="https://www.starlette.io/background/"class="external-link"target="_blank">la documentation officielle de Starlette sur les tâches d'arrière-plan</a> (via leurs classes `BackgroundTasks`et `BackgroundTask`).
Plus de détails sont disponibles dans <ahref="https://www.starlette.dev/background/"class="external-link"target="_blank">la documentation officielle de Starlette sur les tâches d'arrière-plan</a> (via leurs classes `BackgroundTasks`et `BackgroundTask`).
@ -140,7 +140,7 @@ Vous pourriez aussi l'utiliser pour générer du code automatiquement, pour les
`FastAPI` est une classe héritant directement de `Starlette`.
Vous pouvez donc aussi utiliser toutes les fonctionnalités de <ahref="https://www.starlette.io/"class="external-link"target="_blank">Starlette</a> depuis `FastAPI`.
Vous pouvez donc aussi utiliser toutes les fonctionnalités de <ahref="https://www.starlette.dev/"class="external-link"target="_blank">Starlette</a> depuis `FastAPI`.