mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-25 17:57:09 +00:00
♻️(summary) reorganize API code
I totally reorganized the API code, to gain in clarity.
This commit is contained in:
committed by
aleb_the_flash
parent
b12b14b277
commit
35741a1bc1
@@ -0,0 +1 @@
|
||||
"""Summary Api package."""
|
||||
@@ -0,0 +1,17 @@
|
||||
"""API routes related to application health checking."""
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/__heartbeat__")
|
||||
async def heartbeat():
|
||||
"""Health check endpoint for monitoring."""
|
||||
return
|
||||
|
||||
|
||||
@router.get("/__lbheartbeat__")
|
||||
async def lbheartbeat():
|
||||
"""Health check endpoint for load balancer."""
|
||||
return
|
||||
@@ -0,0 +1,9 @@
|
||||
"""API routes."""
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from summary.api.route import tasks
|
||||
from summary.core.security import verify_token
|
||||
|
||||
api_router = APIRouter(dependencies=[Depends(verify_token)])
|
||||
api_router.include_router(tasks.router, tags=["tasks"])
|
||||
@@ -0,0 +1 @@
|
||||
"""Summary Api Route package."""
|
||||
@@ -0,0 +1,34 @@
|
||||
"""API routes related to application tasks."""
|
||||
|
||||
from celery.result import AsyncResult
|
||||
from fastapi import APIRouter
|
||||
from pydantic import BaseModel
|
||||
|
||||
from summary.core.celery_worker import process_audio_transcribe_summarize
|
||||
|
||||
|
||||
class TaskCreation(BaseModel):
|
||||
"""Task data."""
|
||||
|
||||
filename: str
|
||||
email: str
|
||||
sub: str
|
||||
|
||||
|
||||
router = APIRouter(prefix="/tasks")
|
||||
|
||||
|
||||
@router.post("/")
|
||||
async def create_task(request: TaskCreation):
|
||||
"""Create a task."""
|
||||
task = process_audio_transcribe_summarize.delay(
|
||||
request.filename, request.email, request.sub
|
||||
)
|
||||
return {"id": task.id, "message": "Task created"}
|
||||
|
||||
|
||||
@router.get("/{task_id}")
|
||||
async def get_task_status(task_id: str):
|
||||
"""Check task status by ID."""
|
||||
task = AsyncResult(task_id)
|
||||
return {"id": task_id, "status": task.status}
|
||||
Reference in New Issue
Block a user