Created
June 30, 2022 18:10
-
-
Save theinfosecguy/f11dca885cfd004b4d343afdbf360634 to your computer and use it in GitHub Desktop.
Python FastAPI Basic API Setup
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
from fastapi import FastAPI | |
app = FastAPI() | |
todo_items = [] | |
@app.get("/health") | |
def health(): | |
return {"status": "ok"} | |
@app.get("/") | |
def get_items(): | |
return {"items": todo_items} | |
@app.post("/") | |
def add_item(request: dict): | |
todo_items.append(request["item"]) | |
return {"status": "ok", "message": "Item added"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment