INNER CODE UNIT · Python

send_email

doganarif/fastapi-radar · example_app.py:330

async def send_email(email: str, subject: str, background_tasks: BackgroundTasks):
    """Example endpoint that triggers a background task."""
    background_tasks.add_task(send_email_task, email, subject)
    return {"message": "Email will be sent in the background"}


@app.post("/process-report/{user_id}")
async def process_user_report(user_id: int, background_tasks: BackgroundTasks):
    """Example endpoint that triggers a long-running background task."""
    background_tasks.add_task(process_report, user_id)
    return {"message": "Report processing started"}


@app.post("/generate-analytics")
async def generate_analytics_endpoint(
    background_tasks: BackgroundTasks, days: int = Query(7, ge=1, le=365)
):
    """Generate analytics for the specified number of days."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…