Spaces:
No application file
No application file
File size: 675 Bytes
caa08b8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from fastapi import FastAPI
from database import db
from models.patient import Patient # On importe ton modèle
app = FastAPI()
@app.get("/")
async def bonjour():
return {"message": "Serveur MedConnect actif !"}
# Nouvelle route pour enregistrer un patient
@app.post("/patients")
async def creer_patient(patient: Patient):
# On transforme les données en dictionnaire pour MongoDB
nouveau_patient = patient.model_dump()
# On l'insère dans une collection nommée "liste_patients"
resultat = await db.liste_patients.insert_one(nouveau_patient)
return {"id": str(resultat.inserted_id), "status": "Patient enregistré !"} |