Spaces:
Runtime error
Runtime error
Update app.py
Browse files1234594 unmodified lines10010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415544 unmodified lines200201202203204205206# librariesfrom flask import Flask, render_template, request, redirect, url_for, flash, session, send_from_directoryimport osimport loggingfrom utility.utils import extract_text_from_images, Data_Extractor, json_to_llm_str, process_extracted_text, process_resume_data94 unmodified linesfrom 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), 400try:# Fetch the file from the provided URLresponse = requests.get(file_url)if response.status_code == 200:# Extract filename from the URLoutput_filename = os.path.basename(file_url)output_path = os.path.join(UPLOAD_FOLDER, output_filename)# Save the file to the output folderwith 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 detailsresponse_data = {'status': 'success','file_name': output_filename,'file_path': output_path,'message': f'File {output_filename} downloaded and stored successfully'}return jsonify(response_data), 200else: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), 400except 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 linessession['processed_Img'] = processed_Imgflash('Data processed and analyzed successfully')logging.info("Data processed and analyzed successfully")return redirect(url_for('result'))@app.route('/result')def result():1234594 unmodified lines10010110210310410544 unmodified lines150151152153154155156157158159# librariesfrom 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 linesfrom flask import jsonify@app.route('/process/<filename>', methods=['POST'])def process_file(filename):uploaded_files = session.get('uploaded_files', [])44 unmodified linessession['processed_Img'] = processed_Imgflash('Data processed and analyzed successfully')logging.info("Data processed and analyzed successfully")return jsonify('process_data':[processed_data],'process_image': processed_Img)@app.route('/result')def result():
app.py+5-52