Spaces:
Build error
Build error
read_item
Browse files
main.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
|
@@ -6,3 +7,8 @@ app = FastAPI()
|
|
| 6 |
@app.get("/")
|
| 7 |
def read_root():
|
| 8 |
return {"Hello": "World!"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from typing import Union
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
|
|
|
| 7 |
@app.get("/")
|
| 8 |
def read_root():
|
| 9 |
return {"Hello": "World!"}
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@app.get("/items/{item_id}")
|
| 13 |
+
def read_item(item_id: int, q: Union[str, None] = None):
|
| 14 |
+
return {"item_id": item_id, "q": q}
|