Skip to content

Instantly share code, notes, and snippets.

@theinfosecguy
Created June 30, 2022 18:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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