cleanup
Build and Push Docker Images / build-and-push (push) Successful in 2m32s

This commit is contained in:
2025-07-12 16:26:22 +02:00
parent 5f5941703c
commit 2f724d0c1f
9 changed files with 306 additions and 288 deletions
+31 -1
View File
@@ -8,7 +8,8 @@ from app.services.browser import (
extract_seo_service,
extract_meta_tags_service,
detect_pagination_service,
capture_outgoing_calls_service
capture_outgoing_calls_service,
fetch_json_service
)
router = APIRouter()
@@ -152,4 +153,33 @@ async def capture_outgoing_calls(url: str, skipCache: bool = False, x_api_key: O
return result
except Exception as e:
print(f"Error capturing outgoing calls for URL {decoded_url}: {e}")
raise HTTPException(status_code=500, detail=str(e))
@router.get("/json")
async def fetch_json(url: str, skipCache: bool = False, x_api_key: Optional[str] = Header(None)):
"""Fetch JSON content from a website"""
# Validate API key
if not x_api_key or x_api_key != API_KEY:
raise HTTPException(status_code=401, detail="Invalid API key")
# Decode URL if it's encoded
decoded_url = unquote(url)
# Check cache first (unless skipCache is True)
if not skipCache:
cached_result = get_cached_data(decoded_url, "json")
if cached_result:
return cached_result
try:
# Call the service function
result = await fetch_json_service(decoded_url)
# Save to cache
if(result["status"] == "success"):
save_to_cache(decoded_url, "json", result)
return result
except Exception as e:
print(f"Error fetching JSON for URL {decoded_url}: {e}")
raise HTTPException(status_code=500, detail=str(e))