Skip to content

Instantly share code, notes, and snippets.

@dmateos
Created August 5, 2020 09:30
Show Gist options
  • Save dmateos/98699bc563804e42e961240c8cef4fb9 to your computer and use it in GitHub Desktop.
Save dmateos/98699bc563804e42e961240c8cef4fb9 to your computer and use it in GitHub Desktop.
1 import fastapi
2 import pydantic
3 import typing
4
5
6 app = fastapi.FastAPI()
7
8
9 class Blob(pydantic.BaseModel):
10 handle: str
11 data: str
12 lifetime: int
13
14
15 @app.get("/")
16 def root():
17 return {"hello world": "test"}
18
19
20 @app.get("/{blob_id")
21 def get_blob(blob_id: int, q: typing.Optional[str] = None):
22 return {"id": blob_id, "q": q}
23
24
25 @app.post("/{blob_id}")
26 def push_blob(blob_id: int, blob: Blob):
27 return {"id": blob_id}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment