Code Explainers

Code explainers tagged #background-tasks

python
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, status
from pydantic import BaseModel, EmailStr
from sqlalchemy.orm import Session
 

Building a signup endpoint in FastAPI

dependency-injection request-validation background-tasks
Intermediate 8 steps
python
import asyncio
import logging
from contextlib import asynccontextmanager
from datetime import datetime, timedelta, timezone

A background session cleaner in FastAPI

background-tasks asyncio lifespan
Intermediate 8 steps
python
import json
import logging
 
import stripe

Handling Stripe webhooks in Django

webhooks signature-verification idempotency
Intermediate 7 steps