Skip to content

Instantly share code, notes, and snippets.

@bobfang1992
Created October 20, 2020 08:36
Show Gist options
  • Save bobfang1992/5c38a08e05a4e229f6047be98da88fce to your computer and use it in GitHub Desktop.
Save bobfang1992/5c38a08e05a4e229f6047be98da88fce to your computer and use it in GitHub Desktop.
from fastapi import FastAPI
import uuid
app = FastAPI()
COM_API_OBJECT = {}
@app.get("/create")
async def create():
client_id = uuid.uuid()
COM_API_OBJECT[str(client_id)] = "Some object that cannot be shared among processes"
return {"client_id": client_id}
@app.get("/do_stuff")
async def do_stuff(client_id:str, stuff: str):
client = COM_API_OBJECT[client_id]
print(f"{client} is doing {stuff}")
return {"ok": True}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment