Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# libraries
|
| 2 |
-
from flask import Flask, render_template, request, redirect, url_for, flash, session, send_from_directory
|
| 3 |
import os
|
| 4 |
import logging
|
| 5 |
from utility.utils import extract_text_from_images, Data_Extractor, json_to_llm_str, process_extracted_text, process_resume_data
|
|
@@ -100,56 +100,6 @@ def remove_file():
|
|
| 100 |
|
| 101 |
from flask import jsonify
|
| 102 |
|
| 103 |
-
@app.route('/download_and_store', methods=['GET'])
|
| 104 |
-
def download_and_store():
|
| 105 |
-
file_url = request.args.get('file_url')
|
| 106 |
-
|
| 107 |
-
if not file_url:
|
| 108 |
-
response = {
|
| 109 |
-
'status': 'error',
|
| 110 |
-
'message': 'No file URL provided'
|
| 111 |
-
}
|
| 112 |
-
logging.warning("No file URL provided")
|
| 113 |
-
return jsonify(response), 400
|
| 114 |
-
|
| 115 |
-
try:
|
| 116 |
-
# Fetch the file from the provided URL
|
| 117 |
-
response = requests.get(file_url)
|
| 118 |
-
if response.status_code == 200:
|
| 119 |
-
# Extract filename from the URL
|
| 120 |
-
output_filename = os.path.basename(file_url)
|
| 121 |
-
output_path = os.path.join(UPLOAD_FOLDER, output_filename)
|
| 122 |
-
|
| 123 |
-
# Save the file to the output folder
|
| 124 |
-
with open(output_path, 'wb') as f:
|
| 125 |
-
f.write(response.content)
|
| 126 |
-
|
| 127 |
-
logging.info(f"File {output_filename} downloaded and saved to {output_path}")
|
| 128 |
-
|
| 129 |
-
# JSON response with file details
|
| 130 |
-
response_data = {
|
| 131 |
-
'status': 'success',
|
| 132 |
-
'file_name': output_filename,
|
| 133 |
-
'file_path': output_path,
|
| 134 |
-
'message': f'File {output_filename} downloaded and stored successfully'
|
| 135 |
-
}
|
| 136 |
-
return jsonify(response_data), 200
|
| 137 |
-
else:
|
| 138 |
-
response_data = {
|
| 139 |
-
'status': 'error',
|
| 140 |
-
'message': f"Failed to download file from {file_url}. Status code: {response.status_code}"
|
| 141 |
-
}
|
| 142 |
-
logging.error(f"Failed to download file from {file_url}. Status code: {response.status_code}")
|
| 143 |
-
return jsonify(response_data), 400
|
| 144 |
-
|
| 145 |
-
except Exception as e:
|
| 146 |
-
logging.error(f"Error downloading file from {file_url}: {e}")
|
| 147 |
-
response_data = {
|
| 148 |
-
'status': 'error',
|
| 149 |
-
'message': f"Error downloading file from {file_url}: {str(e)}"
|
| 150 |
-
}
|
| 151 |
-
return jsonify(response_data), 500
|
| 152 |
-
|
| 153 |
@app.route('/process/<filename>', methods=['POST'])
|
| 154 |
def process_file(filename):
|
| 155 |
uploaded_files = session.get('uploaded_files', [])
|
|
@@ -200,7 +150,10 @@ def process_file(filename):
|
|
| 200 |
session['processed_Img'] = processed_Img
|
| 201 |
flash('Data processed and analyzed successfully')
|
| 202 |
logging.info("Data processed and analyzed successfully")
|
| 203 |
-
return
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
@app.route('/result')
|
| 206 |
def result():
|
|
|
|
| 1 |
# libraries
|
| 2 |
+
from flask import Flask, render_template, request, redirect, url_for, flash, session, send_from_directory, jsonify
|
| 3 |
import os
|
| 4 |
import logging
|
| 5 |
from utility.utils import extract_text_from_images, Data_Extractor, json_to_llm_str, process_extracted_text, process_resume_data
|
|
|
|
| 100 |
|
| 101 |
from flask import jsonify
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
@app.route('/process/<filename>', methods=['POST'])
|
| 104 |
def process_file(filename):
|
| 105 |
uploaded_files = session.get('uploaded_files', [])
|
|
|
|
| 150 |
session['processed_Img'] = processed_Img
|
| 151 |
flash('Data processed and analyzed successfully')
|
| 152 |
logging.info("Data processed and analyzed successfully")
|
| 153 |
+
return jsonify(
|
| 154 |
+
'process_data':[processed_data],
|
| 155 |
+
'process_image': processed_Img
|
| 156 |
+
)
|
| 157 |
|
| 158 |
@app.route('/result')
|
| 159 |
def result():
|