Update main.py
Browse files
main.py
CHANGED
|
@@ -100,9 +100,12 @@ async def simulate_interview(request: Request):
|
|
| 100 |
|
| 101 |
# --- Endpoint pour l'analyse de CV ---
|
| 102 |
@app.post("/parse-cv/", tags=["CV Parsing"])
|
| 103 |
-
async def parse_cv(
|
|
|
|
|
|
|
|
|
|
| 104 |
"""
|
| 105 |
-
Analyse un fichier CV (PDF) et
|
| 106 |
"""
|
| 107 |
if file.content_type != "application/pdf":
|
| 108 |
raise HTTPException(status_code=400, detail="Fichier PDF requis")
|
|
@@ -114,7 +117,7 @@ async def parse_cv(file: UploadFile = File(...)):
|
|
| 114 |
tmp_path = tmp.name
|
| 115 |
|
| 116 |
try:
|
| 117 |
-
result = await run_in_threadpool(cv_service.parse_cv, tmp_path)
|
| 118 |
finally:
|
| 119 |
if os.path.exists(tmp_path):
|
| 120 |
os.remove(tmp_path)
|
|
@@ -124,16 +127,6 @@ async def parse_cv(file: UploadFile = File(...)):
|
|
| 124 |
|
| 125 |
return result
|
| 126 |
|
| 127 |
-
# --- Endpoint pour récupérer le feedback ---
|
| 128 |
-
@app.get("/get-feedback/{user_id}", response_model=Feedback, tags=["Analysis"])
|
| 129 |
-
async def get_feedback(user_id: str):
|
| 130 |
-
feedback_path = f"/tmp/feedbacks/{user_id}.json"
|
| 131 |
-
if not os.path.exists(feedback_path):
|
| 132 |
-
raise HTTPException(status_code=404, detail="Feedback non trouvé ou non encore traité.")
|
| 133 |
-
with open(feedback_path, "r", encoding="utf-8") as f:
|
| 134 |
-
data = json.load(f)
|
| 135 |
-
return Feedback(**data)
|
| 136 |
-
|
| 137 |
# --- Démarrage de l'application (pour un test local) ---
|
| 138 |
if __name__ == "__main__":
|
| 139 |
import uvicorn
|
|
|
|
| 100 |
|
| 101 |
# --- Endpoint pour l'analyse de CV ---
|
| 102 |
@app.post("/parse-cv/", tags=["CV Parsing"])
|
| 103 |
+
async def parse_cv(
|
| 104 |
+
file: UploadFile = File(...),
|
| 105 |
+
user_id: str = None
|
| 106 |
+
):
|
| 107 |
"""
|
| 108 |
+
Analyse un fichier CV (PDF) et le stocke automatiquement dans MongoDB.
|
| 109 |
"""
|
| 110 |
if file.content_type != "application/pdf":
|
| 111 |
raise HTTPException(status_code=400, detail="Fichier PDF requis")
|
|
|
|
| 117 |
tmp_path = tmp.name
|
| 118 |
|
| 119 |
try:
|
| 120 |
+
result = await run_in_threadpool(cv_service.parse_cv, tmp_path, user_id)
|
| 121 |
finally:
|
| 122 |
if os.path.exists(tmp_path):
|
| 123 |
os.remove(tmp_path)
|
|
|
|
| 127 |
|
| 128 |
return result
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
# --- Démarrage de l'application (pour un test local) ---
|
| 131 |
if __name__ == "__main__":
|
| 132 |
import uvicorn
|