Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from supabase_utils import save_law_to_supabase
|
|
| 7 |
from helpers.indexer import build_indexed_response
|
| 8 |
from helpers.blocks_all import extract_from_url
|
| 9 |
from parser.extract_tables_by_article import extract_tables_from_url
|
| 10 |
-
|
| 11 |
|
| 12 |
app = FastAPI(
|
| 13 |
title="Text Extractor API",
|
|
@@ -53,8 +53,13 @@ class IndexedURLRequest(BaseModel):
|
|
| 53 |
ranges: Optional[List[List[int]]] = None
|
| 54 |
|
| 55 |
|
|
|
|
|
|
|
| 56 |
@app.post("/extract")
|
| 57 |
-
async def extract_indexed(
|
|
|
|
|
|
|
|
|
|
| 58 |
try:
|
| 59 |
# 1) استخراج النصوص الخام من الرابط
|
| 60 |
raw_texts = await extract_from_url(str(request.url), request.timeout)
|
|
@@ -83,9 +88,11 @@ async def extract_indexed(request: IndexedURLRequest):
|
|
| 83 |
return datalist
|
| 84 |
|
| 85 |
except Exception as e:
|
| 86 |
-
raise HTTPException(
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
| 89 |
# ============================
|
| 90 |
# نقطة GET بسيطة لإرجاع النصوص بدون فهرسة
|
| 91 |
# ============================
|
|
|
|
| 7 |
from helpers.indexer import build_indexed_response
|
| 8 |
from helpers.blocks_all import extract_from_url
|
| 9 |
from parser.extract_tables_by_article import extract_tables_from_url
|
| 10 |
+
import os
|
| 11 |
|
| 12 |
app = FastAPI(
|
| 13 |
title="Text Extractor API",
|
|
|
|
| 53 |
ranges: Optional[List[List[int]]] = None
|
| 54 |
|
| 55 |
|
| 56 |
+
from fastapi import Depends
|
| 57 |
+
|
| 58 |
@app.post("/extract")
|
| 59 |
+
async def extract_indexed(
|
| 60 |
+
request: IndexedURLRequest,
|
| 61 |
+
_: None = Depends(verify_api_token)
|
| 62 |
+
):
|
| 63 |
try:
|
| 64 |
# 1) استخراج النصوص الخام من الرابط
|
| 65 |
raw_texts = await extract_from_url(str(request.url), request.timeout)
|
|
|
|
| 88 |
return datalist
|
| 89 |
|
| 90 |
except Exception as e:
|
| 91 |
+
raise HTTPException(
|
| 92 |
+
status_code=500,
|
| 93 |
+
detail=f"خطأ في معالجة المحتوى: {str(e)}"
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
# ============================
|
| 97 |
# نقطة GET بسيطة لإرجاع النصوص بدون فهرسة
|
| 98 |
# ============================
|