geeksiddhant commited on
Commit
6d4031d
·
1 Parent(s): 595e8cd

Update API URL

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -21,8 +21,8 @@ class APIClient:
21
  # Get the Hugging Face Space URL from environment or use localhost
22
  space_id = os.getenv("SPACE_ID") # Hugging Face Spaces provides this automatically
23
  if space_id:
24
- # In Hugging Face Spaces, the FastAPI service will be available at port 8000
25
- self.base_url = f"https://{space_id}.hf.space/api" # Updated URL format
26
  else:
27
  # Local development
28
  self.base_url = "http://localhost:8000"
@@ -37,7 +37,8 @@ class APIClient:
37
 
38
  def get(self, endpoint: str):
39
  try:
40
- response = requests.get(f"{self.base_url}{endpoint}")
 
41
  return self._handle_response(response)
42
  except Exception as e:
43
  st.error(f"API Error: {str(e)}")
@@ -87,7 +88,7 @@ def search_profiles(query: str):
87
  try:
88
  response = requests.post(
89
  f"{api.base_url}/api/search",
90
- json={"query": query} # Send query in correct format
91
  )
92
  if not response.ok:
93
  if response.status_code == 422:
 
21
  # Get the Hugging Face Space URL from environment or use localhost
22
  space_id = os.getenv("SPACE_ID") # Hugging Face Spaces provides this automatically
23
  if space_id:
24
+ # In Hugging Face Spaces, the FastAPI service will be available at port 7860
25
+ self.base_url = f"https://{space_id}.hf.space" # Remove /api from base_url
26
  else:
27
  # Local development
28
  self.base_url = "http://localhost:8000"
 
37
 
38
  def get(self, endpoint: str):
39
  try:
40
+ # Add /api prefix to all endpoints
41
+ response = requests.get(f"{self.base_url}/api{endpoint}")
42
  return self._handle_response(response)
43
  except Exception as e:
44
  st.error(f"API Error: {str(e)}")
 
88
  try:
89
  response = requests.post(
90
  f"{api.base_url}/api/search",
91
+ json={"query": query}
92
  )
93
  if not response.ok:
94
  if response.status_code == 422: