from fastapi import FastAPI
from upstash_workflow.fastapi import Serve
from upstash_workflow import AsyncWorkflowContext
app = FastAPI()
serve = Serve(app)
@serve.post("/api/example")
async def example(context: AsyncWorkflowContext[str]) -> None:
async def _step1() -> str:
# define a piece of business logic as step 1
return "step 1 result"
result = await context.run("step-1", _step1)
async def _step2() -> None:
# define another piece of business logic as step 2
pass
await context.run("step-2", _step2)