mirror of
https://github.com/fastapi/fastapi.git
synced 2026-07-14 17:03:09 -04:00
📝 Update docs, add first tutorials
This commit is contained in:
8
docs/tutorial/src/first-steps/tutorial002.py
Normal file
8
docs/tutorial/src/first-steps/tutorial002.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
my_awesome_api = FastAPI()
|
||||
|
||||
|
||||
@my_awesome_api.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
8
docs/tutorial/src/first-steps/tutorial003.py
Normal file
8
docs/tutorial/src/first-steps/tutorial003.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"message": "Hello World"}
|
||||
11
docs/tutorial/src/query-params/tutorial005.py
Normal file
11
docs/tutorial/src/query-params/tutorial005.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/users/{user_id}/items/{item_id}")
|
||||
async def read_user_item(
|
||||
user_id: int, item_id: str, needy: str
|
||||
):
|
||||
item = {"item_id": item_id, "owner_id": user_id, "needy": needy}
|
||||
return item
|
||||
@@ -1,17 +0,0 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/users/{user_id}/items/{item_id}")
|
||||
async def read_user_item(
|
||||
user_id: int, item_id: str, needy: str, q: str = None, short: bool = False
|
||||
):
|
||||
item = {"item_id": item_id, "owner_id": user_id, "needy": needy}
|
||||
if q:
|
||||
item.update({"q": q})
|
||||
if not short:
|
||||
item.update(
|
||||
{"description": "This is an amazing item that has a long description"}
|
||||
)
|
||||
return item
|
||||
Reference in New Issue
Block a user