This commit is contained in:
@@ -13,7 +13,7 @@ from app.services.browser import (
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/")
|
||||
async def visit_url(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
async def visit_url(url: str, skipCache: bool = False, x_api_key: Optional[str] = Header(None)):
|
||||
# Validate API key
|
||||
if not x_api_key or x_api_key != API_KEY:
|
||||
raise HTTPException(status_code=401, detail="Invalid API key")
|
||||
@@ -21,7 +21,8 @@ async def visit_url(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
# Decode URL if it's encoded
|
||||
decoded_url = unquote(url)
|
||||
|
||||
# Check cache first
|
||||
# Check cache first (unless skipCache is True)
|
||||
if not skipCache:
|
||||
cached_result = get_cached_data(decoded_url, "visit")
|
||||
if cached_result:
|
||||
return cached_result
|
||||
@@ -30,7 +31,7 @@ async def visit_url(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
# Call the service function
|
||||
result = await visit_url_service(decoded_url)
|
||||
|
||||
# Save to cache
|
||||
# Save to cache (even if we skipped reading from it)
|
||||
save_to_cache(decoded_url, "visit", result)
|
||||
|
||||
return result
|
||||
@@ -39,7 +40,7 @@ async def visit_url(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@router.get("/seo")
|
||||
async def extract_seo(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
async def extract_seo(url: str, skipCache: bool = False, x_api_key: Optional[str] = Header(None)):
|
||||
"""Extract SEO information from a website"""
|
||||
# Validate API key
|
||||
if not x_api_key or x_api_key != API_KEY:
|
||||
@@ -48,7 +49,8 @@ async def extract_seo(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
# Decode URL if it's encoded
|
||||
decoded_url = unquote(url)
|
||||
|
||||
# Check cache first
|
||||
# Check cache first (unless skipCache is True)
|
||||
if not skipCache:
|
||||
cached_result = get_cached_data(decoded_url, "seo")
|
||||
if cached_result:
|
||||
return cached_result
|
||||
@@ -65,7 +67,7 @@ async def extract_seo(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@router.get("/meta")
|
||||
async def extract_meta_tags(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
async def extract_meta_tags(url: str, skipCache: bool = False, x_api_key: Optional[str] = Header(None)):
|
||||
"""Extract meta tags from a website"""
|
||||
# Validate API key
|
||||
if not x_api_key or x_api_key != API_KEY:
|
||||
@@ -74,7 +76,8 @@ async def extract_meta_tags(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
# Decode URL if it's encoded
|
||||
decoded_url = unquote(url)
|
||||
|
||||
# Check cache first
|
||||
# Check cache first (unless skipCache is True)
|
||||
if not skipCache:
|
||||
cached_result = get_cached_data(decoded_url, "meta")
|
||||
if cached_result:
|
||||
return cached_result
|
||||
@@ -91,7 +94,7 @@ async def extract_meta_tags(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@router.get("/pagination")
|
||||
async def detect_pagination(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
async def detect_pagination(url: str, skipCache: bool = False, x_api_key: Optional[str] = Header(None)):
|
||||
"""Detect pagination on a website and determine the pagination pattern"""
|
||||
# Validate API key
|
||||
if not x_api_key or x_api_key != API_KEY:
|
||||
@@ -100,7 +103,8 @@ async def detect_pagination(url: str, x_api_key: Optional[str] = Header(None)):
|
||||
# Decode URL if it's encoded
|
||||
decoded_url = unquote(url)
|
||||
|
||||
# Check cache first
|
||||
# Check cache first (unless skipCache is True)
|
||||
if not skipCache:
|
||||
cached_result = get_cached_data(decoded_url, "pagination")
|
||||
if cached_result:
|
||||
return cached_result
|
||||
|
||||
Reference in New Issue
Block a user