From 6bc7ece057aabcc1dac33d90a62ed3e65dc43f04 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 13 Jan 2026 15:50:20 +0100 Subject: [PATCH] 13.01.26 --- app.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index d72fe55..dabf994 100644 --- a/app.py +++ b/app.py @@ -832,9 +832,29 @@ def detect_template(text): async def metadata(text: str = Body(..., embed=True)): return extract_report_metadata(text) +import httpx +from io import BytesIO + +async def call_extractor(text: str, lab: str = "AHK"): + url = "http://62.72.36.116:8090/extract" + params = {"lab": lab} + + fake_file = BytesIO(text.encode("utf-8")) + + files = { + "file": ("document.txt", fake_file, "text/plain") + } + + async with httpx.AsyncClient(timeout=60) as client: + r = await client.post(url, params=params, files=files) + r.raise_for_status() + return r.json() + @app.post("/parse") async def parse_endpoint(text: str = Body(..., embed=True)): - return parse_report(text) + lab = parse_report(text) + result = await call_extractor(text, lab=lab) + return result PARSERS = { "AHK": AHKParser(), @@ -862,6 +882,7 @@ def empty_weight_report(lab): def parse_report(text): template=detect_template(text) - if template not in PARSERS: - return {"template":"UNKNOWN"} - return PARSERS[template].parse(text) \ No newline at end of file + # if template not in PARSERS: + # return {"template":"UNKNOWN"} + # return PARSERS[template].parse(text) + return template \ No newline at end of file