pz09-CORVUS-CORAX / LIVE_DEPL

realizacja wdrożenie
GNU General Public License v3.0
1 stars 0 forks source link

PDF VALIDATION - tempfile undefined #9

Closed ja669nle2bil closed 5 months ago

ja669nle2bil commented 5 months ago

Undefined after leaving 'target' route . ..

ja669nle2bil commented 5 months ago

VERY_FIRST_VER if 'pdf_file_path' in session: pdf_path = session['pdf_file_path'] print('pdf_path received ON /validate-pdf:', request.form['pdf_path'])

return jsonify({"message": "Test"}), 200

if 'pdf_path' not in request.form:
    return jsonify({"error": "No pdf_path provided for validartion"})
pdf_path = request.form['pdf_path']
# new log: 17:22-10-04
logging.debug("pdf_path received in validate_pdf route: %s", pdf_path)

#Debugging17:25-10-04
if not os.path.exists(pdf_path):
    print('File does not exist:', pdf_path)
    #log 15:11-10-04
    logging.error("File does not exist after upload (/validate-pdf):", pdf_path) 
    return jsonify({"error": "PDF file not found after upload(/validate-pdf)"}), 404

# test 14:48-10-04
try:
    if not is_pdf_size_valid(pdf_path):
        logging.error("File is empty or corrupt:", pdf_path)
        return jsonify({"error": "PDF size exceeds limit"})
except Exception as e: 
    logging.exception("Unexpected error during validation:", e)
    return jsonify({"error": "Internal server error"}), 500

return jsonify({"isValid": True})
ja669nle2bil commented 5 months ago

resolved -latest commit