utkarsh134 commited on
Commit
148c997
·
verified ·
1 Parent(s): 9d4ca3a

Update api/routes.py

Browse files
Files changed (1) hide show
  1. api/routes.py +6 -3
api/routes.py CHANGED
@@ -1,5 +1,6 @@
1
  from fastapi import APIRouter, File, UploadFile, Form, HTTPException, Response, status
2
  import os
 
3
  from pydantic import BaseModel
4
  from typing import Optional, Dict, Any
5
 
@@ -36,7 +37,9 @@ async def analyze_resume(
36
  Returns:
37
  - Resume analysis with extraction status
38
  """
39
- _, file_extension = os.path.splitext(resume_file.filename)
 
 
40
  file_extension = file_extension.lower()
41
 
42
  allowed_extensions = ['.pdf', '.docx']
@@ -49,12 +52,12 @@ async def analyze_resume(
49
  try:
50
  file_bytes = await resume_file.read()
51
 
52
- # Set environment variable for storage preference
53
  os.environ["STORE_ANALYSIS_RESULT"] = str(store_in_db).lower()
54
 
55
  result = await analyze_resume_document(file_bytes, job_role, file_extension)
56
 
57
- # Return success with storage status
58
  return result
59
 
60
  except Exception as e:
 
1
  from fastapi import APIRouter, File, UploadFile, Form, HTTPException, Response, status
2
  import os
3
+ import urllib.parse
4
  from pydantic import BaseModel
5
  from typing import Optional, Dict, Any
6
 
 
37
  Returns:
38
  - Resume analysis with extraction status
39
  """
40
+
41
+ filename = urllib.parse.unquote(resume_file.filename)
42
+ _, file_extension = os.path.splitext(filename)
43
  file_extension = file_extension.lower()
44
 
45
  allowed_extensions = ['.pdf', '.docx']
 
52
  try:
53
  file_bytes = await resume_file.read()
54
 
55
+
56
  os.environ["STORE_ANALYSIS_RESULT"] = str(store_in_db).lower()
57
 
58
  result = await analyze_resume_document(file_bytes, job_role, file_extension)
59
 
60
+
61
  return result
62
 
63
  except Exception as e: