Browse Source

🎨 Auto format

pull/15506/head
pre-commit-ci-lite[bot] 1 month ago
committed by GitHub
parent
commit
0e08b16516
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      docs_src/openapi_callbacks/tutorial002_py310.py

21
docs_src/openapi_callbacks/tutorial002_py310.py

@ -10,7 +10,6 @@ class PassageProcessingRequest(BaseModel):
callback_url: str callback_url: str
@app.post("/callback") @app.post("/callback")
async def callback(request: Request): async def callback(request: Request):
""" """
@ -27,9 +26,7 @@ async def callback(request: Request):
print(data) print(data)
return { return {"received": True}
"received": True
}
async def send_processing_result(callback_url: str, generated_passage: str): async def send_processing_result(callback_url: str, generated_passage: str):
@ -40,17 +37,13 @@ async def send_processing_result(callback_url: str, generated_passage: str):
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
await client.post( await client.post(
callback_url, callback_url,
json={ json={"processed_passage": generated_passage, "status": "completed"},
"processed_passage": generated_passage,
"status": "completed"
}
) )
@app.post("/process-passage") @app.post("/process-passage")
async def process_passage( async def process_passage(
data: PassageProcessingRequest, data: PassageProcessingRequest, background_tasks: BackgroundTasks
background_tasks: BackgroundTasks
): ):
""" """
Receives a passage processing request from the client. Receives a passage processing request from the client.
@ -64,11 +57,7 @@ async def process_passage(
""" """
background_tasks.add_task( background_tasks.add_task(
send_processing_result, send_processing_result, data.callback_url, data.passage_topic
data.callback_url,
data.passage_topic
) )
return { return {"message": "Passage processing started"}
"message": "Passage processing started"
}

Loading…
Cancel
Save