Add
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from Scheduler import Schedule
|
|
| 11 |
from Evaluator import InterviewEvaluator
|
| 12 |
import json
|
| 13 |
import os
|
|
|
|
| 14 |
# At the top with imports
|
| 15 |
from werkzeug.utils import secure_filename
|
| 16 |
|
|
@@ -55,9 +56,28 @@ def allowed_file(filename):
|
|
| 55 |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
| 56 |
|
| 57 |
# Add this endpoint (before /parse)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
@app.route("/upload-candidate-list", methods=["POST"])
|
| 59 |
def upload_candidate_list():
|
| 60 |
try:
|
|
|
|
|
|
|
|
|
|
| 61 |
if 'candidate_list' not in request.files:
|
| 62 |
return jsonify({"error": "No CSV file provided"}), 400
|
| 63 |
|
|
@@ -70,9 +90,9 @@ def upload_candidate_list():
|
|
| 70 |
# Save as test.csv for the scheduler to use
|
| 71 |
filepath = os.path.join('.', 'test.csv')
|
| 72 |
file.save(filepath)
|
|
|
|
| 73 |
|
| 74 |
# Validate CSV format
|
| 75 |
-
import pandas as pd
|
| 76 |
try:
|
| 77 |
df = pd.read_csv(filepath)
|
| 78 |
required_columns = ['Name', 'Email']
|
|
@@ -83,12 +103,14 @@ def upload_candidate_list():
|
|
| 83 |
"found_columns": list(df.columns)
|
| 84 |
}), 400
|
| 85 |
|
|
|
|
| 86 |
return jsonify({
|
| 87 |
"output": f"Successfully uploaded candidate list with {len(df)} candidates",
|
| 88 |
"candidates": len(df)
|
| 89 |
})
|
| 90 |
|
| 91 |
except Exception as e:
|
|
|
|
| 92 |
return jsonify({"error": f"Invalid CSV format: {str(e)}"}), 400
|
| 93 |
else:
|
| 94 |
return jsonify({"error": "File must be a CSV"}), 400
|
|
|
|
| 11 |
from Evaluator import InterviewEvaluator
|
| 12 |
import json
|
| 13 |
import os
|
| 14 |
+
import pandas as pd
|
| 15 |
# At the top with imports
|
| 16 |
from werkzeug.utils import secure_filename
|
| 17 |
|
|
|
|
| 56 |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
| 57 |
|
| 58 |
# Add this endpoint (before /parse)
|
| 59 |
+
@app.route("/test-upload", methods=["POST"])
|
| 60 |
+
def test_upload():
|
| 61 |
+
try:
|
| 62 |
+
logging.info(f"Test upload - Content type: {request.content_type}")
|
| 63 |
+
logging.info(f"Test upload - Files: {list(request.files.keys())}")
|
| 64 |
+
logging.info(f"Test upload - Form data: {list(request.form.keys())}")
|
| 65 |
+
|
| 66 |
+
return jsonify({
|
| 67 |
+
"content_type": request.content_type,
|
| 68 |
+
"files": list(request.files.keys()),
|
| 69 |
+
"form": list(request.form.keys())
|
| 70 |
+
})
|
| 71 |
+
except Exception as e:
|
| 72 |
+
logging.error(f"Test upload error: {str(e)}")
|
| 73 |
+
return jsonify({"error": str(e)}), 500
|
| 74 |
+
|
| 75 |
@app.route("/upload-candidate-list", methods=["POST"])
|
| 76 |
def upload_candidate_list():
|
| 77 |
try:
|
| 78 |
+
logging.info(f"Received request with content type: {request.content_type}")
|
| 79 |
+
logging.info(f"Request files: {list(request.files.keys())}")
|
| 80 |
+
|
| 81 |
if 'candidate_list' not in request.files:
|
| 82 |
return jsonify({"error": "No CSV file provided"}), 400
|
| 83 |
|
|
|
|
| 90 |
# Save as test.csv for the scheduler to use
|
| 91 |
filepath = os.path.join('.', 'test.csv')
|
| 92 |
file.save(filepath)
|
| 93 |
+
logging.info(f"Saved CSV file to: {filepath}")
|
| 94 |
|
| 95 |
# Validate CSV format
|
|
|
|
| 96 |
try:
|
| 97 |
df = pd.read_csv(filepath)
|
| 98 |
required_columns = ['Name', 'Email']
|
|
|
|
| 103 |
"found_columns": list(df.columns)
|
| 104 |
}), 400
|
| 105 |
|
| 106 |
+
logging.info(f"Successfully validated CSV with {len(df)} candidates")
|
| 107 |
return jsonify({
|
| 108 |
"output": f"Successfully uploaded candidate list with {len(df)} candidates",
|
| 109 |
"candidates": len(df)
|
| 110 |
})
|
| 111 |
|
| 112 |
except Exception as e:
|
| 113 |
+
logging.error(f"CSV validation error: {str(e)}")
|
| 114 |
return jsonify({"error": f"Invalid CSV format: {str(e)}"}), 400
|
| 115 |
else:
|
| 116 |
return jsonify({"error": "File must be a CSV"}), 400
|