Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 53, in application
response = frappe.api.handle()
File “apps/frappe/frappe/api.py”, line 53, in handle
return RESTAPIHandler(call, doctype, name).get_response()
File “apps/frappe/frappe/api.py”, line 69, in get_response
return self.handle_method()
File “apps/frappe/frappe/api.py”, line 79, in handle_method
return frappe.handler.handle()
File “apps/frappe/frappe/handler.py”, line 48, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/handler.py”, line 86, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “apps/frappe/frappe/init.py”, line 1591, in call
return fn(*args, **newargs)
File “apps/frappe/frappe/utils/typing_validations.py”, line 33, in wrapper
return func(*args, **kwargs)
File “apps/turiya_app/turiya_app/quiz.py”, line 66, in pdfconvertor
frappe.throw((“No file found”))
File “apps/frappe/frappe/init.py”, line 523, in throw
msgprint(
File “apps/frappe/frappe/init.py”, line 491, in msgprint
_raise_exception()
File “apps/frappe/frappe/init.py”, line 440, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: No file found
This is my code
Please upload pdf here
<form id="upload-form" method="post" enctype="multipart/form-data">
<!-- <label for="file">Choose file:</label> -->
<input type="file" id="file" name="file" accept=".pdf" />
<input type="submit" value="Upload" id="upload-button" disabled />
</form>
<div id="errordisplay"></div>
after uploading pdf i summarize the data in that file. it works in another frappe-bench. Here it always gives the above error. same code only. How to solve. I tried bench update --reset also
this is my python code
@frappe.whitelist(allow_guest=True)
def pdfconvertor():
if ‘file’ in frappe.request.files:
file = frappe.request.files[‘file’]
# Read the PDF and extract data
text = read_pdf(file)
# return text
# Clean the extracted text
# cleaned_text = clean_data(text)
# Summarize the cleaned text
summarized_text = summarize_text_with_sumy(text, 20) # Adjust the second parameter to change the number of sentences in the summary
return summarized_text
else:
frappe.throw(_(“No file found”))
@frappe.whitelist(allow_guest=True)
def read_pdf(file):
resource_manager = PDFResourceManager()
fake_file_handle = io.StringIO()
converter = TextConverter(resource_manager, fake_file_handle, laparams=LAParams())
page_interpreter = PDFPageInterpreter(resource_manager, converter)
for page in PDFPage.get_pages(BytesIO(file.read()), set()):
page_interpreter.process_page(page)
text = fake_file_handle.getvalue()
converter.close()
fake_file_handle.close()
if text:
return text
please help on that. thankyou