Created
October 20, 2020 08:36
-
-
Save bobfang1992/5c38a08e05a4e229f6047be98da88fce to your computer and use it in GitHub Desktop.
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 | |
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