Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2980,28 +2980,34 @@ async def test_whatsjet_payloads(phone: str):
|
|
2980 |
# Test endpoint for cPanel image access
|
2981 |
@app.get("/test-cpanel-image-access")
|
2982 |
async def test_cpanel_image_access():
|
2983 |
-
"""
|
|
|
|
|
2984 |
try:
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2991 |
result = {
|
2992 |
"image_url": image_url,
|
2993 |
-
"accessible": response.status_code == 200,
|
2994 |
"status_code": response.status_code,
|
|
|
|
|
2995 |
"timestamp": datetime.now().isoformat()
|
2996 |
}
|
2997 |
-
|
2998 |
if response.status_code == 200:
|
2999 |
logger.info(f"[Test] β
cPanel image URL is now accessible!")
|
3000 |
else:
|
3001 |
logger.warning(f"[Test] β cPanel image URL still not accessible (status {response.status_code})")
|
3002 |
-
|
3003 |
return result
|
3004 |
-
|
3005 |
except Exception as e:
|
3006 |
logger.error(f"[Test] Error testing cPanel image access: {e}")
|
3007 |
return {
|
|
|
2980 |
# Test endpoint for cPanel image access
|
2981 |
@app.get("/test-cpanel-image-access")
|
2982 |
async def test_cpanel_image_access():
|
2983 |
+
"""
|
2984 |
+
Test endpoint to check if cPanel image URLs are now accessible with browser-like headers.
|
2985 |
+
"""
|
2986 |
try:
|
2987 |
+
image_url = "https://amgocus.com/uploads/images/Respira%20Aid%20Plus.jpg"
|
2988 |
+
# Test with browser-like headers
|
2989 |
+
headers = {
|
2990 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
2991 |
+
'Accept': 'image/webp,image/apng,image/*,*/*;q=0.8',
|
2992 |
+
'Accept-Language': 'en-US,en;q=0.9',
|
2993 |
+
'Accept-Encoding': 'gzip, deflate, br',
|
2994 |
+
'Connection': 'keep-alive',
|
2995 |
+
'Upgrade-Insecure-Requests': '1'
|
2996 |
+
}
|
2997 |
+
logger.info(f"[Test] Testing cPanel image URL with browser headers: {image_url}")
|
2998 |
+
response = requests.get(image_url, headers=headers, timeout=10, stream=True, allow_redirects=True)
|
2999 |
result = {
|
3000 |
"image_url": image_url,
|
|
|
3001 |
"status_code": response.status_code,
|
3002 |
+
"headers": dict(response.headers),
|
3003 |
+
"accessible": response.status_code == 200,
|
3004 |
"timestamp": datetime.now().isoformat()
|
3005 |
}
|
|
|
3006 |
if response.status_code == 200:
|
3007 |
logger.info(f"[Test] β
cPanel image URL is now accessible!")
|
3008 |
else:
|
3009 |
logger.warning(f"[Test] β cPanel image URL still not accessible (status {response.status_code})")
|
|
|
3010 |
return result
|
|
|
3011 |
except Exception as e:
|
3012 |
logger.error(f"[Test] Error testing cPanel image access: {e}")
|
3013 |
return {
|