ciyidogan commited on
Commit
1681f11
·
verified ·
1 Parent(s): 11a0f16

Update admin_routes.py

Browse files
Files changed (1) hide show
  1. admin_routes.py +16 -3
admin_routes.py CHANGED
@@ -818,6 +818,10 @@ async def test_api(api: APICreate, username: str = Depends(verify_token)):
818
  try:
819
  # Prepare request
820
  headers = api.headers.copy()
 
 
 
 
821
 
822
  # Make request
823
  response = requests.request(
@@ -826,7 +830,8 @@ async def test_api(api: APICreate, username: str = Depends(verify_token)):
826
  headers=headers,
827
  json=api.body_template if api.method in ["POST", "PUT", "PATCH"] else None,
828
  params=api.body_template if api.method == "GET" else None,
829
- timeout=api.timeout_seconds
 
830
  )
831
 
832
  return {
@@ -834,12 +839,20 @@ async def test_api(api: APICreate, username: str = Depends(verify_token)):
834
  "status_code": response.status_code,
835
  "response_time_ms": int(response.elapsed.total_seconds() * 1000),
836
  "headers": dict(response.headers),
837
- "body": response.text[:1000] # First 1000 chars
 
 
 
 
 
 
 
838
  }
839
  except Exception as e:
840
  return {
841
  "success": False,
842
- "error": str(e)
 
843
  }
844
 
845
  @router.get("/activity-log")
 
818
  try:
819
  # Prepare request
820
  headers = api.headers.copy()
821
+
822
+ # Add sample auth token for testing
823
+ if api.auth and api.auth.get("enabled"):
824
+ headers["Authorization"] = "Bearer test_token_12345"
825
 
826
  # Make request
827
  response = requests.request(
 
830
  headers=headers,
831
  json=api.body_template if api.method in ["POST", "PUT", "PATCH"] else None,
832
  params=api.body_template if api.method == "GET" else None,
833
+ timeout=api.timeout_seconds,
834
+ proxies={"http": api.proxy, "https": api.proxy} if api.proxy else None
835
  )
836
 
837
  return {
 
839
  "status_code": response.status_code,
840
  "response_time_ms": int(response.elapsed.total_seconds() * 1000),
841
  "headers": dict(response.headers),
842
+ "body": response.text[:1000], # First 1000 chars
843
+ "request_headers": headers, # Debug için
844
+ "request_body": api.body_template # Debug için
845
+ }
846
+ except requests.exceptions.Timeout:
847
+ return {
848
+ "success": False,
849
+ "error": f"Request timed out after {api.timeout_seconds} seconds"
850
  }
851
  except Exception as e:
852
  return {
853
  "success": False,
854
+ "error": str(e),
855
+ "error_type": type(e).__name__
856
  }
857
 
858
  @router.get("/activity-log")