Skip to content

Instantly share code, notes, and snippets.

@theinfosecguy
Created June 30, 2022 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theinfosecguy/f11dca885cfd004b4d343afdbf360634 to your computer and use it in GitHub Desktop.
Save theinfosecguy/f11dca885cfd004b4d343afdbf360634 to your computer and use it in GitHub Desktop.
Python FastAPI Basic API Setup
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