Spaces:
Runtime error
Runtime error
Update app.py
Browse files12234594 unmodified lines10010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115210310410544 unmodified lines150151152203153154155156157158159# librariesfrom flask import Flask, render_template, request, redirect, url_for, flash, session, send_from_directoryfrom flask import Flask, render_template, request, redirect, url_for, flash, session, send_from_directory, jsonifyimport osimport loggingfrom utility.utils import extract_text_from_images, Data_Extractor, json_to_llm_str, process_extracted_text, process_resume_data94 unmodified lines
from flask import jsonify
@app.route('/download_and_store', methods=['GET'])def download_and_store(): file_url = request.args.get('file_url') if not file_url: response = { 'status': 'error', 'message': 'No file URL provided' } logging.warning("No file URL provided") return jsonify(response), 400 try: # Fetch the file from the provided URL response = requests.get(file_url) if response.status_code == 200: # Extract filename from the URL output_filename = os.path.basename(file_url) output_path = os.path.join(UPLOAD_FOLDER, output_filename) # Save the file to the output folder with open(output_path, 'wb') as f: f.write(response.content) logging.info(f"File {output_filename} downloaded and saved to {output_path}") # JSON response with file details response_data = { 'status': 'success', 'file_name': output_filename, 'file_path': output_path, 'message': f'File {output_filename} downloaded and stored successfully' } return jsonify(response_data), 200 else: response_data = { 'status': 'error', 'message': f"Failed to download file from {file_url}. Status code: {response.status_code}" } logging.error(f"Failed to download file from {file_url}. Status code: {response.status_code}") return jsonify(response_data), 400 except Exception as e: logging.error(f"Error downloading file from {file_url}: {e}") response_data = { 'status': 'error', 'message': f"Error downloading file from {file_url}: {str(e)}" } return jsonify(response_data), 500
@app.route('/process/<filename>', methods=['POST'])def process_file(filename): uploaded_files = session.get('uploaded_files', [])44 unmodified lines session['processed_Img'] = processed_Img flash('Data processed and analyzed successfully') logging.info("Data processed and analyzed successfully") return redirect(url_for('result')) return jsonify( 'process_data':[processed_data], 'process_image': processed_Img )
@app.route('/result')def result():app.py+5-52