Created
September 5, 2024 19:58
-
-
Save davila7/c2cd473c7eb628d2e46c5ad2501653db to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from fastapi import FastAPI | |
| app = FastAPI() | |
| @app.get("/") | |
| def read_root(): | |
| return {"Hello1": "World"} | |
| @app.get("/items/") | |
| def read_items(): | |
| return [{"name": "Item Foo"}, {"name": "Item Bar"}] | |
| @app.get("/items/{item_id}") | |
| def read_item(item_id: int): | |
| return {"item_id": item_id} | |
| @app.post("/items/") | |
| def create_item(name: str, price: float): | |
| return {"name": name, "price": price} | |
| @app.put("/items/{item_id}") | |
| def update_item(item_id: int, name: str, price: float): | |
| return {"item_id": item_id, "name": name, "price": price} | |
| @app.delete("/items/{item_id}") | |
| def delete_item(item_id: int): | |
| return {"item_id": item_id} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment