Fix
Browse files- backend/runner/app.py +20 -15
backend/runner/app.py
CHANGED
|
@@ -134,22 +134,27 @@ def presign_upload():
|
|
| 134 |
}
|
| 135 |
"""
|
| 136 |
run_id = uuid.uuid4().hex
|
| 137 |
-
# We'll use a local file path as the "imageKey"
|
| 138 |
image_key = f"artifacts/{run_id}.jpg"
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
#
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
return response
|
| 154 |
|
| 155 |
|
|
|
|
| 134 |
}
|
| 135 |
"""
|
| 136 |
run_id = uuid.uuid4().hex
|
|
|
|
| 137 |
image_key = f"artifacts/{run_id}.jpg"
|
| 138 |
+
|
| 139 |
+
# Fix: Use the correct Hugging Face Space URL
|
| 140 |
+
# In Hugging Face Spaces, we need to construct the URL properly
|
| 141 |
+
if os.getenv("HF_SPACE_URL"):
|
| 142 |
+
# Use environment variable if set
|
| 143 |
+
base_url = os.getenv("HF_SPACE_URL")
|
| 144 |
+
else:
|
| 145 |
+
# Fallback: try to get from request headers or use default
|
| 146 |
+
base_url = request.headers.get('X-Forwarded-Proto', 'https') + "://" + request.headers.get('X-Forwarded-Host', request.host)
|
| 147 |
+
|
| 148 |
+
upload_url = f"{base_url}/upload/{run_id}"
|
| 149 |
+
|
| 150 |
+
response = jsonify({
|
| 151 |
+
"runId": run_id,
|
| 152 |
+
"imageKey": image_key,
|
| 153 |
+
"upload": {
|
| 154 |
+
"url": upload_url,
|
| 155 |
+
"fields": {},
|
| 156 |
+
},
|
| 157 |
+
})
|
| 158 |
return response
|
| 159 |
|
| 160 |
|