Skip to content

Commit

Permalink
Merge branch 'master' into ru_translate_deploy_index
Browse files Browse the repository at this point in the history
  • Loading branch information
Xewus committed Nov 1, 2022
2 parents 2545c37 + d0917ce commit 80359a7
Show file tree
Hide file tree
Showing 30 changed files with 2,174 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/actions/notify-translations/app/translations.yml
Expand Up @@ -17,3 +17,4 @@ nl: 4701
uz: 4883
sv: 5146
he: 5157
ta: 5434
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Expand Up @@ -38,7 +38,7 @@ jobs:
name: docs-zip
path: ./docs.zip
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v1.2.3
uses: nwtgck/actions-netlify@v1.2.4
with:
publish-dir: './site'
production-branch: master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/preview-docs.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Download Artifact Docs
uses: dawidd6/action-download-artifact@v2.23.0
uses: dawidd6/action-download-artifact@v2.24.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-docs.yml
Expand All @@ -25,7 +25,7 @@ jobs:
rm -f docs.zip
- name: Deploy to Netlify
id: netlify
uses: nwtgck/actions-netlify@v1.2.3
uses: nwtgck/actions-netlify@v1.2.4
with:
publish-dir: './site'
production-deploy: false
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -19,7 +19,7 @@ repos:
- --py3-plus
- --keep-runtime-typing
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.6
rev: v1.7.7
hooks:
- id: autoflake
args:
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/alternatives.md
Expand Up @@ -123,7 +123,7 @@ That's why when talking about version 2.0 it's common to say "Swagger", and for

There are several Flask REST frameworks, but after investing the time and work into investigating them, I found that many are discontinued or abandoned, with several standing issues that made them unfit.

### <a href="https://marshmallow.readthedocs.io/en/3.0/" class="external-link" target="_blank">Marshmallow</a>
### <a href="https://marshmallow.readthedocs.io/en/stable/" class="external-link" target="_blank">Marshmallow</a>

One of the main features needed by API systems is data "<abbr title="also called marshalling, conversion">serialization</abbr>" which is taking data from the code (Python) and converting it into something that can be sent through the network. For example, converting an object containing data from a database into a JSON object. Converting `datetime` objects into strings, etc.

Expand Down
6 changes: 3 additions & 3 deletions docs/en/docs/async.md
Expand Up @@ -403,17 +403,17 @@ All that is what powers FastAPI (through Starlette) and what makes it have such

When you declare a *path operation function* with normal `def` instead of `async def`, it is run in an external threadpool that is then awaited, instead of being called directly (as it would block the server).

If you are coming from another async framework that does not work in the way described above and you are used to define trivial compute-only *path operation functions* with plain `def` for a tiny performance gain (about 100 nanoseconds), please note that in **FastAPI** the effect would be quite opposite. In these cases, it's better to use `async def` unless your *path operation functions* use code that performs blocking <abbr title="Input/Output: disk reading or writing, network communications.">I/O</abbr>.
If you are coming from another async framework that does not work in the way described above and you are used to defining trivial compute-only *path operation functions* with plain `def` for a tiny performance gain (about 100 nanoseconds), please note that in **FastAPI** the effect would be quite opposite. In these cases, it's better to use `async def` unless your *path operation functions* use code that performs blocking <abbr title="Input/Output: disk reading or writing, network communications.">I/O</abbr>.

Still, in both situations, chances are that **FastAPI** will [still be faster](/#performance){.internal-link target=_blank} than (or at least comparable to) your previous framework.

### Dependencies

The same applies for dependencies. If a dependency is a standard `def` function instead of `async def`, it is run in the external threadpool.
The same applies for [dependencies](/tutorial/dependencies/index.md){.internal-link target=_blank}. If a dependency is a standard `def` function instead of `async def`, it is run in the external threadpool.

### Sub-dependencies

You can have multiple dependencies and sub-dependencies requiring each other (as parameters of the function definitions), some of them might be created with `async def` and some with normal `def`. It would still work, and the ones created with normal `def` would be called on an external thread (from the threadpool) instead of being "awaited".
You can have multiple dependencies and [sub-dependencies](/tutorial/dependencies/sub-dependencies.md){.internal-link target=_blank} requiring each other (as parameters of the function definitions), some of them might be created with `async def` and some with normal `def`. It would still work, and the ones created with normal `def` would be called on an external thread (from the threadpool) instead of being "awaited".

### Other utility functions

Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/contributing.md
Expand Up @@ -108,7 +108,7 @@ After activating the environment as described above:
<div class="termy">

```console
$ pip install -e .[dev,doc,test]
$ pip install -e ."[dev,doc,test]"

---> 100%
```
Expand Down
35 changes: 35 additions & 0 deletions docs/en/docs/release-notes.md
Expand Up @@ -2,6 +2,41 @@

## Latest Changes


## 0.85.2

### Docs

* ✏ Fix grammar and add helpful links to dependencies in `docs/en/docs/async.md`. PR [#5432](https://github.com/tiangolo/fastapi/pull/5432) by [@pamelafox](https://github.com/pamelafox).
* ✏ Fix broken link in `alternatives.md`. PR [#5455](https://github.com/tiangolo/fastapi/pull/5455) by [@su-shubham](https://github.com/su-shubham).
* ✏ Fix typo in docs about contributing, for compatibility with `pip` in Zsh. PR [#5523](https://github.com/tiangolo/fastapi/pull/5523) by [@zhangbo2012](https://github.com/zhangbo2012).
* 📝 Fix typo in docs with examples for Python 3.10 instead of 3.9. PR [#5545](https://github.com/tiangolo/fastapi/pull/5545) by [@feliciss](https://github.com/feliciss).

### Translations

* 🌐 Add Portuguese translation for `docs/pt/docs/tutorial/request-forms.md`. PR [#4934](https://github.com/tiangolo/fastapi/pull/4934) by [@batlopes](https://github.com/batlopes).
* 🌐 Add Chinese translation for `docs/zh/docs/tutorial/dependencies/classes-as-dependencies.md`. PR [#4971](https://github.com/tiangolo/fastapi/pull/4971) by [@Zssaer](https://github.com/Zssaer).
* 🌐 Add French translation for `deployment/deta.md`. PR [#3692](https://github.com/tiangolo/fastapi/pull/3692) by [@rjNemo](https://github.com/rjNemo).
* 🌐 Update Chinese translation for `docs/zh/docs/tutorial/query-params-str-validations.md`. PR [#5255](https://github.com/tiangolo/fastapi/pull/5255) by [@hjlarry](https://github.com/hjlarry).
* 🌐 Add Chinese translation for `docs/zh/docs/tutorial/sql-databases.md`. PR [#4999](https://github.com/tiangolo/fastapi/pull/4999) by [@Zssaer](https://github.com/Zssaer).
* 🌐 Add Chinese translation for `docs/zh/docs/advanced/wsgi.md`. PR [#4505](https://github.com/tiangolo/fastapi/pull/4505) by [@ASpathfinder](https://github.com/ASpathfinder).
* 🌐 Add Portuguese translation for `docs/pt/docs/tutorial/body-multiple-params.md`. PR [#4111](https://github.com/tiangolo/fastapi/pull/4111) by [@lbmendes](https://github.com/lbmendes).
* 🌐 Add Portuguese translation for `docs/pt/docs/tutorial/path-params-numeric-validations.md`. PR [#4099](https://github.com/tiangolo/fastapi/pull/4099) by [@lbmendes](https://github.com/lbmendes).
* 🌐 Add French translation for `deployment/versions.md`. PR [#3690](https://github.com/tiangolo/fastapi/pull/3690) by [@rjNemo](https://github.com/rjNemo).
* 🌐 Add French translation for `docs/fr/docs/help-fastapi.md`. PR [#2233](https://github.com/tiangolo/fastapi/pull/2233) by [@JulianMaurin](https://github.com/JulianMaurin).
* 🌐 Fix typo in Chinese translation for `docs/zh/docs/tutorial/security/first-steps.md`. PR [#5530](https://github.com/tiangolo/fastapi/pull/5530) by [@yuki1sntSnow](https://github.com/yuki1sntSnow).
* 🌐 Add Portuguese translation for `docs/pt/docs/tutorial/response-status-code.md`. PR [#4922](https://github.com/tiangolo/fastapi/pull/4922) by [@batlopes](https://github.com/batlopes).
* 🔧 Add config for Tamil translations. PR [#5563](https://github.com/tiangolo/fastapi/pull/5563) by [@tiangolo](https://github.com/tiangolo).

### Internal

* ⬆ Bump internal dependency mypy from 0.971 to 0.982. PR [#5541](https://github.com/tiangolo/fastapi/pull/5541) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump nwtgck/actions-netlify from 1.2.3 to 1.2.4. PR [#5507](https://github.com/tiangolo/fastapi/pull/5507) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump internal dependency types-ujson from 5.4.0 to 5.5.0. PR [#5537](https://github.com/tiangolo/fastapi/pull/5537) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump dawidd6/action-download-artifact from 2.23.0 to 2.24.0. PR [#5508](https://github.com/tiangolo/fastapi/pull/5508) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Update internal dependency pytest-cov requirement from <4.0.0,>=2.12.0 to >=2.12.0,<5.0.0. PR [#5539](https://github.com/tiangolo/fastapi/pull/5539) by [@dependabot[bot]](https://github.com/apps/dependabot).
*[pre-commit.ci] pre-commit autoupdate. PR [#5536](https://github.com/tiangolo/fastapi/pull/5536) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
* 🐛 Fix internal Trio test warnings. PR [#5547](https://github.com/tiangolo/fastapi/pull/5547) by [@samuelcolvin](https://github.com/samuelcolvin).
*[pre-commit.ci] pre-commit autoupdate. PR [#5408](https://github.com/tiangolo/fastapi/pull/5408) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
* ⬆️ Upgrade Typer to include Rich in scripts for docs. PR [#5502](https://github.com/tiangolo/fastapi/pull/5502) by [@tiangolo](https://github.com/tiangolo).
* 🐛 Fix calling `mkdocs` for languages as a subprocess to fix/enable MkDocs Material search plugin. PR [#5501](https://github.com/tiangolo/fastapi/pull/5501) by [@tiangolo](https://github.com/tiangolo).
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/tutorial/request-files.md
Expand Up @@ -124,7 +124,7 @@ You can make a file optional by using standard type annotations and setting a de
{!> ../../../docs_src/request_files/tutorial001_02.py!}
```

=== "Python 3.9 and above"
=== "Python 3.10 and above"

```Python hl_lines="7 14"
{!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
Expand Down
245 changes: 245 additions & 0 deletions docs/fr/docs/deployment/deta.md
@@ -0,0 +1,245 @@
# Déployer FastAPI sur Deta

Dans cette section, vous apprendrez à déployer facilement une application **FastAPI** sur <a href="https://www.deta.
sh/?ref=fastapi" class="external-link" target="_blank">Deta</a> en utilisant le plan tarifaire gratuit. 🎁

Cela vous prendra environ **10 minutes**.

!!! info
<a href="https://www.deta.sh/?ref=fastapi" class="external-link" target="_blank">Deta</a> sponsorise **FastAPI**. 🎉

## Une application **FastAPI** de base

* Créez un répertoire pour votre application, par exemple `./fastapideta/` et déplacez-vous dedans.

### Le code FastAPI

* Créer un fichier `main.py` avec :

```Python
from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
```

### Dépendances

Maintenant, dans le même répertoire, créez un fichier `requirements.txt` avec :

```text
fastapi
```

!!! tip "Astuce"
Il n'est pas nécessaire d'installer Uvicorn pour déployer sur Deta, bien qu'il soit probablement souhaitable de l'installer localement pour tester votre application.

### Structure du répertoire

Vous aurez maintenant un répertoire `./fastapideta/` avec deux fichiers :

```
.
└── main.py
└── requirements.txt
```

## Créer un compte gratuit sur Deta

Créez maintenant un <a href="https://www.deta.sh/?ref=fastapi" class="external-link" target="_blank">compte gratuit
sur Deta</a>, vous avez juste besoin d'une adresse email et d'un mot de passe.

Vous n'avez même pas besoin d'une carte de crédit.

## Installer le CLI (Interface en Ligne de Commande)

Une fois que vous avez votre compte, installez le <abbr title="Command Line Interface application">CLI</abbr> de Deta :

=== "Linux, macOS"

<div class="termy">

```console
$ curl -fsSL https://get.deta.dev/cli.sh | sh
```

</div>

=== "Windows PowerShell"

<div class="termy">

```console
$ iwr https://get.deta.dev/cli.ps1 -useb | iex
```

</div>

Après l'avoir installé, ouvrez un nouveau terminal afin que la nouvelle installation soit détectée.

Dans un nouveau terminal, confirmez qu'il a été correctement installé avec :

<div class="termy">

```console
$ deta --help

Deta command line interface for managing deta micros.
Complete documentation available at https://docs.deta.sh

Usage:
deta [flags]
deta [command]

Available Commands:
auth Change auth settings for a deta micro

...
```

</div>

!!! tip "Astuce"
Si vous rencontrez des problèmes pour installer le CLI, consultez la <a href="https://docs.deta. sh/docs/micros/getting_started?ref=fastapi" class="external-link" target="_blank">documentation officielle de Deta (en anglais)</a>.

## Connexion avec le CLI

Maintenant, connectez-vous à Deta depuis le CLI avec :

<div class="termy">

```console
$ deta login

Please, log in from the web page. Waiting..
Logged in successfully.
```

</div>

Cela ouvrira un navigateur web et permettra une authentification automatique.

## Déployer avec Deta

Ensuite, déployez votre application avec le CLI de Deta :

<div class="termy">

```console
$ deta new

Successfully created a new micro

// Notice the "endpoint" 🔍

{
"name": "fastapideta",
"runtime": "python3.7",
"endpoint": "https://qltnci.deta.dev",
"visor": "enabled",
"http_auth": "enabled"
}

Adding dependencies...


---> 100%


Successfully installed fastapi-0.61.1 pydantic-1.7.2 starlette-0.13.6
```

</div>

Vous verrez un message JSON similaire à :

```JSON hl_lines="4"
{
"name": "fastapideta",
"runtime": "python3.7",
"endpoint": "https://qltnci.deta.dev",
"visor": "enabled",
"http_auth": "enabled"
}
```

!!! tip "Astuce"
Votre déploiement aura une URL `"endpoint"` différente.

## Vérifiez

Maintenant, dans votre navigateur ouvrez votre URL `endpoint`. Dans l'exemple ci-dessus, c'était
`https://qltnci.deta.dev`, mais la vôtre sera différente.

Vous verrez la réponse JSON de votre application FastAPI :

```JSON
{
"Hello": "World"
}
```

Et maintenant naviguez vers `/docs` dans votre API, dans l'exemple ci-dessus ce serait `https://qltnci.deta.dev/docs`.

Vous verrez votre documentation comme suit :

<img src="/img/deployment/deta/image01.png">

## Activer l'accès public

Par défaut, Deta va gérer l'authentification en utilisant des cookies pour votre compte.

Mais une fois que vous êtes prêt, vous pouvez le rendre public avec :

<div class="termy">

```console
$ deta auth disable

Successfully disabled http auth
```

</div>

Maintenant, vous pouvez partager cette URL avec n'importe qui et ils seront en mesure d'accéder à votre API. 🚀

## HTTPS

Félicitations ! Vous avez déployé votre application FastAPI sur Deta ! 🎉 🍰

Remarquez également que Deta gère correctement HTTPS pour vous, vous n'avez donc pas à vous en occuper et pouvez être sûr que vos clients auront une connexion cryptée sécurisée. ✅ 🔒

## Vérifiez le Visor

À partir de l'interface graphique de votre documentation (dans une URL telle que `https://qltnci.deta.dev/docs`)
envoyez une requête à votre *opération de chemin* `/items/{item_id}`.

Par exemple avec l'ID `5`.

Allez maintenant sur <a href="https://web.deta.sh/" class="external-link" target="_blank">https://web.deta.sh</a>.

Vous verrez qu'il y a une section à gauche appelée <abbr title="ça vient de Micro(server)">"Micros"</abbr> avec chacune de vos applications.

Vous verrez un onglet avec "Details", et aussi un onglet "Visor", allez à l'onglet "Visor".

Vous pouvez y consulter les requêtes récentes envoyées à votre application.

Vous pouvez également les modifier et les relancer.

<img src="/img/deployment/deta/image02.png">

## En savoir plus

À un moment donné, vous voudrez probablement stocker certaines données pour votre application d'une manière qui
persiste dans le temps. Pour cela, vous pouvez utiliser <a href="https://docs.deta.sh/docs/base/py_tutorial?ref=fastapi" class="external-link" target="_blank">Deta Base</a>, il dispose également d'un généreux **plan gratuit**.

Vous pouvez également en lire plus dans la <a href="https://docs.deta.sh?ref=fastapi" class="external-link" target="_blank">documentation Deta</a>.

0 comments on commit 80359a7

Please sign in to comment.