-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update (frameworks/fastapi): two versions and documentation
- Loading branch information
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
# FastAPI | ||
https://fastapi.tiangolo.com/ | ||
|
||
# Installing | ||
|
||
This statement forces a specific version of FastAPI installation when the default is not the latest. | ||
|
||
~~~ | ||
pip3 install "fastapi[standard]"==0.112.0 | ||
~~~ | ||
|
||
# Simple Example | ||
|
||
* Version for Python 3.7+ using `Union[ ]` for optional fields: | ||
~~~ | ||
fastapi dev main_3_07.py | ||
~~~ | ||
|
||
* Version for Python 3.10+ using `type | None` for optional fields: | ||
~~~ | ||
fastapi dev main_3_10.py | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
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, q: str | None = None): | ||
return {"item_id": item_id, "q": q} |