Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -320,6 +320,56 @@ def findapiAllDocNoNotbilled():
|
|
| 320 |
|
| 321 |
|
| 322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
################################################################################################################################################################
|
| 325 |
################################################################################################################################################################
|
|
|
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
+
@app.route('/findapitobebilledonlyNewmarthe', methods=['GET','POST'])
|
| 324 |
+
def findapitobebilledonlymarthe():
|
| 325 |
+
try:
|
| 326 |
+
data = request.get_json(force=True) or {}
|
| 327 |
+
pdfLink = data.get('filePath')
|
| 328 |
+
if not pdfLink:
|
| 329 |
+
return jsonify({"error": "Missing 'filePath'"}), 400
|
| 330 |
+
pdfbytes, pdf_document, tablepdfoutput, alltext , filename= InitialMarkups.extract_section_under_header_tobebilled2marthe(pdfLink)
|
| 331 |
+
# return jsonify(tablepdfoutput)
|
| 332 |
+
# Parse JSON string → list of dicts
|
| 333 |
+
data = json.loads(tablepdfoutput)
|
| 334 |
+
|
| 335 |
+
# Collect all body parts
|
| 336 |
+
html_body = ""
|
| 337 |
+
|
| 338 |
+
for section in data:
|
| 339 |
+
if "head above 2" in section:
|
| 340 |
+
html_body += f"<h1>{section['head above 2']}</h1><br>"
|
| 341 |
+
|
| 342 |
+
if "head above 1" in section:
|
| 343 |
+
html_body += f"<h2>{section['head above 1']}</h2><br>"
|
| 344 |
+
|
| 345 |
+
if "Subject" in section:
|
| 346 |
+
html_body += f"<h3>{section['Subject']}</h3><br>"
|
| 347 |
+
if "BodyText" in section:
|
| 348 |
+
html_body += f"<p>{' '.join(section['BodyText'])}</p><br>"
|
| 349 |
+
# html_body += f"<div>{' '.join(section['bodytext'])}</div><br>"
|
| 350 |
+
|
| 351 |
+
# Wrap everything into one HTML document
|
| 352 |
+
html_content = f"""
|
| 353 |
+
<!DOCTYPE html>
|
| 354 |
+
<html>
|
| 355 |
+
<head>
|
| 356 |
+
<title>{filename}</title>
|
| 357 |
+
<meta charset="utf-8">
|
| 358 |
+
</head>
|
| 359 |
+
<body>
|
| 360 |
+
{html_body}
|
| 361 |
+
</body>
|
| 362 |
+
</html>
|
| 363 |
+
"""
|
| 364 |
+
# return Response(html_content, mimetype="text/html", headers={"Filename": filename})
|
| 365 |
+
return jsonify({"input_data": html_content,"Filename:":filename})
|
| 366 |
+
# return Response(html_content, mimetype="text/html", headers={"Filename": filename})
|
| 367 |
+
except Exception as e:
|
| 368 |
+
print(f"Error in /findapitobebilledonly: {e}")
|
| 369 |
+
return jsonify({"error": str(e)}), 500
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
|
| 373 |
|
| 374 |
################################################################################################################################################################
|
| 375 |
################################################################################################################################################################
|