Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,6 +93,7 @@ def view_pdf():
|
|
| 93 |
)
|
| 94 |
|
| 95 |
|
|
|
|
| 96 |
@app.route('/get-pdf')
|
| 97 |
def get_pdf():
|
| 98 |
"""Serve the processed PDF."""
|
|
@@ -382,6 +383,57 @@ def findapitobebilledonlymarthe():
|
|
| 382 |
|
| 383 |
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
################################################################################################################################################################
|
| 386 |
################################################################################################################################################################
|
| 387 |
##################### For Rawan - MC Connection ###########################################################################################################
|
|
|
|
| 93 |
)
|
| 94 |
|
| 95 |
|
| 96 |
+
|
| 97 |
@app.route('/get-pdf')
|
| 98 |
def get_pdf():
|
| 99 |
"""Serve the processed PDF."""
|
|
|
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
+
@app.route('/findapitobebilledonlyNewMultiplePDFSmarthe', methods=['GET','POST'])
|
| 387 |
+
def findapitobebilledonlymultple():
|
| 388 |
+
try:
|
| 389 |
+
data = request.get_json(force=True) or {}
|
| 390 |
+
pdfLink = data.get('filePath')
|
| 391 |
+
if not pdfLink:
|
| 392 |
+
return jsonify({"error": "Missing 'filePath'"}), 400
|
| 393 |
+
pdfbytes, pdf_document, tablepdfoutput, alltext , filename= InitialMarkups.extract_section_under_header_tobebilledMultiplePDFSmarthe(pdfLink)
|
| 394 |
+
# return jsonify(tablepdfoutput)
|
| 395 |
+
# Parse JSON string → list of dicts
|
| 396 |
+
data = json.loads(tablepdfoutput)
|
| 397 |
+
|
| 398 |
+
# Collect all body parts
|
| 399 |
+
html_body = ""
|
| 400 |
+
|
| 401 |
+
for section in data:
|
| 402 |
+
if "head above 2" in section:
|
| 403 |
+
html_body += f"<h1>{section['head above 2']}</h1><br>"
|
| 404 |
+
|
| 405 |
+
if "head above 1" in section:
|
| 406 |
+
html_body += f"<h2>{section['head above 1']}</h2><br>"
|
| 407 |
+
|
| 408 |
+
if "Subject" in section:
|
| 409 |
+
html_body += f"<h3>{section['Subject']}</h3><br>"
|
| 410 |
+
if "BodyText" in section:
|
| 411 |
+
html_body += f"<p>{' '.join(section['BodyText'])}</p><br>"
|
| 412 |
+
# html_body += f"<div>{' '.join(section['bodytext'])}</div><br>"
|
| 413 |
+
|
| 414 |
+
# Wrap everything into one HTML document
|
| 415 |
+
html_content = f"""
|
| 416 |
+
<!DOCTYPE html>
|
| 417 |
+
<html>
|
| 418 |
+
<head>
|
| 419 |
+
<title>{filename}</title>
|
| 420 |
+
<meta charset="utf-8">
|
| 421 |
+
</head>
|
| 422 |
+
<body>
|
| 423 |
+
{html_body}
|
| 424 |
+
</body>
|
| 425 |
+
</html>
|
| 426 |
+
"""
|
| 427 |
+
# return Response(html_content, mimetype="text/html", headers={"Filename": filename})
|
| 428 |
+
return jsonify({"input_data": html_content,"Filename:":filename})
|
| 429 |
+
# return Response(html_content, mimetype="text/html", headers={"Filename": filename})
|
| 430 |
+
except Exception as e:
|
| 431 |
+
print(f"Error in /findapitobebilledonly: {e}")
|
| 432 |
+
return jsonify({"error": str(e)}), 500
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
|
| 437 |
################################################################################################################################################################
|
| 438 |
################################################################################################################################################################
|
| 439 |
##################### For Rawan - MC Connection ###########################################################################################################
|