asimfayaz commited on
Commit
343f117
·
1 Parent(s): b73c7e6

Update API to return full URLs in job status responses

Browse files

- Modified get_job_status method to transform relative URLs to absolute URLs
- Added environment-aware base URL detection for Hugging Face Spaces deployment
- Updated API documentation to show correct base URLs for deployed space
- URLs now include https://asimfayaz-hunyuan3d-2-1.hf.space for production

Files changed (2) hide show
  1. API_README.md +7 -0
  2. gradio_app.py +18 -1
API_README.md CHANGED
@@ -3,6 +3,13 @@
3
  This document describes the REST API endpoints for the Hunyuan3D-2.1 service.
4
 
5
  ## Base URL
 
 
 
 
 
 
 
6
  ```
7
  http://localhost:7860
8
  ```
 
3
  This document describes the REST API endpoints for the Hunyuan3D-2.1 service.
4
 
5
  ## Base URL
6
+
7
+ For the deployed Hugging Face Space:
8
+ ```
9
+ https://asimfayaz-hunyuan3d-2-1.hf.space
10
+ ```
11
+
12
+ For local development:
13
  ```
14
  http://localhost:7860
15
  ```
gradio_app.py CHANGED
@@ -1155,7 +1155,24 @@ if __name__ == '__main__':
1155
  }
1156
 
1157
  if job.status == JobStatus.COMPLETED:
1158
- response["model_urls"] = job.model_urls
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1159
  elif job.status == JobStatus.FAILED:
1160
  response["error"] = job.error_message
1161
 
 
1155
  }
1156
 
1157
  if job.status == JobStatus.COMPLETED:
1158
+ # Transform relative URLs to absolute URLs
1159
+ absolute_model_urls = {}
1160
+
1161
+ # Determine base URL based on environment
1162
+ if ENV == 'Huggingface':
1163
+ base_url = "https://asimfayaz-hunyuan3d-2-1.hf.space"
1164
+ else:
1165
+ # For local development
1166
+ host_for_url = "localhost" if args.host == "0.0.0.0" else args.host
1167
+ base_url = f"http://{host_for_url}:{args.port}"
1168
+
1169
+ for key, relative_url in job.model_urls.items():
1170
+ if relative_url.startswith('/'):
1171
+ absolute_model_urls[key] = f"{base_url}{relative_url}"
1172
+ else:
1173
+ absolute_model_urls[key] = relative_url
1174
+
1175
+ response["model_urls"] = absolute_model_urls
1176
  elif job.status == JobStatus.FAILED:
1177
  response["error"] = job.error_message
1178