Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, request, redirect, flash, session, render_template, url_for, send_from_directory
|
2 |
import os
|
3 |
import json
|
4 |
import logging
|
@@ -46,7 +46,7 @@ def upload_and_process():
|
|
46 |
"""Handle file upload and process the file."""
|
47 |
if 'file' not in request.files or request.files['file'].filename == '':
|
48 |
flash('No file selected for upload.')
|
49 |
-
return
|
50 |
|
51 |
file = request.files['file']
|
52 |
|
@@ -70,20 +70,25 @@ def upload_and_process():
|
|
70 |
parsed_data = process_resume_data(file_path)
|
71 |
if not parsed_data or 'error' in parsed_data:
|
72 |
flash('An error occurred during file processing.')
|
73 |
-
return
|
74 |
|
75 |
print("file path of files---->",file_path)
|
76 |
session['processed_data'] = parsed_data
|
77 |
session['file_path'] = file_path
|
78 |
flash('File uploaded and data processed successfully.')
|
79 |
-
return
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
except Exception as e:
|
82 |
logging.error(f"File processing error: {str(e)}")
|
83 |
flash('An error occurred while processing the file.')
|
84 |
-
return
|
85 |
else:
|
86 |
-
return
|
87 |
|
88 |
@app.route('/remove_file', methods=['POST'])
|
89 |
def remove_file():
|
|
|
1 |
+
from flask import Flask, request, redirect, flash, session, render_template, url_for, send_from_directory, jsonify
|
2 |
import os
|
3 |
import json
|
4 |
import logging
|
|
|
46 |
"""Handle file upload and process the file."""
|
47 |
if 'file' not in request.files or request.files['file'].filename == '':
|
48 |
flash('No file selected for upload.')
|
49 |
+
return jsonify({'message': "No file selected for upload."})
|
50 |
|
51 |
file = request.files['file']
|
52 |
|
|
|
70 |
parsed_data = process_resume_data(file_path)
|
71 |
if not parsed_data or 'error' in parsed_data:
|
72 |
flash('An error occurred during file processing.')
|
73 |
+
return jsonify({'message': "An error occurred during file processing."})
|
74 |
|
75 |
print("file path of files---->",file_path)
|
76 |
session['processed_data'] = parsed_data
|
77 |
session['file_path'] = file_path
|
78 |
flash('File uploaded and data processed successfully.')
|
79 |
+
return jsonify({
|
80 |
+
'Data': [parsed_data],
|
81 |
+
'process_file': f"https://webashalarforml-resumeextractor3.hf.space/{file_path}",
|
82 |
+
'success': True,
|
83 |
+
'message': 'Data processed and analyzed successfully'
|
84 |
+
})
|
85 |
|
86 |
except Exception as e:
|
87 |
logging.error(f"File processing error: {str(e)}")
|
88 |
flash('An error occurred while processing the file.')
|
89 |
+
return jsonify({'message': "An error occurred while processing the file. Cannot generate results"})
|
90 |
else:
|
91 |
+
return jsonify({'message': "File type not allowed."})
|
92 |
|
93 |
@app.route('/remove_file', methods=['POST'])
|
94 |
def remove_file():
|