root
commited on
Commit
·
2886d7d
1
Parent(s):
5ffd548
fix
Browse files
app.py
CHANGED
|
@@ -10,7 +10,9 @@ import gradio as gr
|
|
| 10 |
# =========================
|
| 11 |
# Config
|
| 12 |
# =========================
|
| 13 |
-
DEFAULT_API_URL = os.environ.get("API_URL")
|
|
|
|
|
|
|
| 14 |
LOGO_IMAGE_PATH = './assets/logo.jpg'
|
| 15 |
GOOGLE_FONTS_URL = "<link href='https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&display=swap' rel='stylesheet'>"
|
| 16 |
LATEX_DELIMS = [
|
|
@@ -102,11 +104,11 @@ def _call_api(api_url: str, file_path: str, use_layout_detection: bool, prompt_l
|
|
| 102 |
resp.raise_for_status()
|
| 103 |
data = resp.json()
|
| 104 |
except requests.exceptions.RequestException as e:
|
| 105 |
-
raise gr.Error(f"API request failed:
|
| 106 |
except json.JSONDecodeError:
|
| 107 |
raise gr.Error(f"Invalid JSON response from server:\n{getattr(resp, 'text', '')}")
|
| 108 |
if data.get("errorCode", -1) != 0:
|
| 109 |
-
raise gr.Error(f"API returned an error:
|
| 110 |
return data
|
| 111 |
|
| 112 |
# =========================
|
|
|
|
| 10 |
# =========================
|
| 11 |
# Config
|
| 12 |
# =========================
|
| 13 |
+
DEFAULT_API_URL = os.environ.get("API_URL")
|
| 14 |
+
if DEFAULT_API_URL and not DEFAULT_API_URL.endswith("/layout-parsing"):
|
| 15 |
+
DEFAULT_API_URL = DEFAULT_API_URL.rstrip("/") + "/layout-parsing"
|
| 16 |
LOGO_IMAGE_PATH = './assets/logo.jpg'
|
| 17 |
GOOGLE_FONTS_URL = "<link href='https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&display=swap' rel='stylesheet'>"
|
| 18 |
LATEX_DELIMS = [
|
|
|
|
| 104 |
resp.raise_for_status()
|
| 105 |
data = resp.json()
|
| 106 |
except requests.exceptions.RequestException as e:
|
| 107 |
+
raise gr.Error(f"API request failed:")
|
| 108 |
except json.JSONDecodeError:
|
| 109 |
raise gr.Error(f"Invalid JSON response from server:\n{getattr(resp, 'text', '')}")
|
| 110 |
if data.get("errorCode", -1) != 0:
|
| 111 |
+
raise gr.Error(f"API returned an error:}")
|
| 112 |
return data
|
| 113 |
|
| 114 |
# =========================
|