🏠 Strona Główna
Benchmarki
📊 Wszystkie benchmarki 🦖 Dinozaur v1 🦖 Dinozaur v2 ✅ Aplikacje To-Do List 🎨 Kreatywne wolne strony 🎯 FSACB - Ostateczny pokaz 🌍 Benchmark tłumaczeń
Modele
🏆 Top 10 modeli 🆓 Darmowe modele 📋 Wszystkie modele ⚙️ Kilo Code
Zasoby
💬 Biblioteka promptów 📖 Słownik AI 🔗 Przydatne linki
Intermédiaire

FastAPI Tâches en Arrière-plan

#python #fastapi #async #backend

Exemple d'utilisation de BackgroundTasks dans FastAPI pour des traitements longs.

Je veux envoyer un email de confirmation après une inscription via mon API FastAPI, mais sans bloquer la réponse HTTP. Montre-moi comment utiliser `BackgroundTasks` pour cela. Fournis le code complet : 1. La fonction d'envoi d'email (simulée). 2. La route d'inscription qui accepte `BackgroundTasks`. 3. L'appel de la tâche en background.