mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-05 20:01:44 -05:00
🎨 Update terminal examples and Typer note (#1139)
* 🎨 Update terminal examples with Termynal * 🍱 Add Termynal scripts and styles from Typer for terminal examples
This commit is contained in:
committed by
GitHub
parent
025b38df40
commit
faf88cea0b
@@ -12,10 +12,14 @@ In your FastAPI application, import and run `uvicorn` directly:
|
||||
|
||||
The main purpose of the `__name__ == "__main__"` is to have some code that is executed when your file is called with:
|
||||
|
||||
```bash
|
||||
python myapp.py
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python myapp.py
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
but is not called when another file imports it, like in:
|
||||
|
||||
```Python
|
||||
@@ -28,10 +32,14 @@ Let's say your file is named `myapp.py`.
|
||||
|
||||
If you run it with:
|
||||
|
||||
```bash
|
||||
python myapp.py
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python myapp.py
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
then the internal variable `__name__` in your file, created automatically by Python, will have as value the string `"__main__"`.
|
||||
|
||||
So, the section:
|
||||
|
||||
Reference in New Issue
Block a user