Spaces:
Paused
Paused
Long Hoang
commited on
Commit
·
d1eac9d
1
Parent(s):
fd84e24
attempt api fix
Browse files- api_client.ts +14 -7
- app.py +1 -1
api_client.ts
CHANGED
|
@@ -92,7 +92,8 @@ export async function processImages(
|
|
| 92 |
process.env.INSTANTSPLAT_SPACE ||
|
| 93 |
"https://longh37-InstantSplat.hf.space";
|
| 94 |
|
| 95 |
-
|
|
|
|
| 96 |
const token = hfToken || process.env.HF_TOKEN;
|
| 97 |
|
| 98 |
console.log(`Connecting to API: ${url}`);
|
|
@@ -121,12 +122,14 @@ export async function processImages(
|
|
| 121 |
|
| 122 |
if (!resp.ok) {
|
| 123 |
const text = await resp.text();
|
|
|
|
|
|
|
| 124 |
console.error(
|
| 125 |
-
`❌ HTTP ${resp.status} ${resp.statusText} from API: ${
|
| 126 |
);
|
| 127 |
return {
|
| 128 |
status: "error",
|
| 129 |
-
error: `HTTP ${resp.status} ${resp.statusText}: ${
|
| 130 |
};
|
| 131 |
}
|
| 132 |
|
|
@@ -137,6 +140,13 @@ export async function processImages(
|
|
| 137 |
status?: string;
|
| 138 |
};
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
const glbUrl = json.glb_url;
|
| 141 |
const plyUrl = json.ply_url;
|
| 142 |
|
|
@@ -160,10 +170,7 @@ export async function processImages(
|
|
| 160 |
console.error("Full error details:", error);
|
| 161 |
return {
|
| 162 |
status: "error",
|
| 163 |
-
error:
|
| 164 |
-
error instanceof Error
|
| 165 |
-
? error.message
|
| 166 |
-
: JSON.stringify(error, Object.getOwnPropertyNames(error))
|
| 167 |
};
|
| 168 |
}
|
| 169 |
}
|
|
|
|
| 92 |
process.env.INSTANTSPLAT_SPACE ||
|
| 93 |
"https://longh37-InstantSplat.hf.space";
|
| 94 |
|
| 95 |
+
// Our FastAPI route is mounted at /base64 (not /api/base64)
|
| 96 |
+
const url = `${baseUrl.replace(/\/+$/, "")}/base64`;
|
| 97 |
const token = hfToken || process.env.HF_TOKEN;
|
| 98 |
|
| 99 |
console.log(`Connecting to API: ${url}`);
|
|
|
|
| 122 |
|
| 123 |
if (!resp.ok) {
|
| 124 |
const text = await resp.text();
|
| 125 |
+
const snippet =
|
| 126 |
+
text.length > 400 ? text.slice(0, 400) + "... [truncated]" : text;
|
| 127 |
console.error(
|
| 128 |
+
`❌ HTTP ${resp.status} ${resp.statusText} from API (body snippet): ${snippet}`
|
| 129 |
);
|
| 130 |
return {
|
| 131 |
status: "error",
|
| 132 |
+
error: `HTTP ${resp.status} ${resp.statusText}: ${snippet}`
|
| 133 |
};
|
| 134 |
}
|
| 135 |
|
|
|
|
| 140 |
status?: string;
|
| 141 |
};
|
| 142 |
|
| 143 |
+
console.log("API response summary:", {
|
| 144 |
+
status: json.status,
|
| 145 |
+
has_glb_url: !!json.glb_url,
|
| 146 |
+
has_ply_url: !!json.ply_url,
|
| 147 |
+
video_available: json.video_available ?? false
|
| 148 |
+
});
|
| 149 |
+
|
| 150 |
const glbUrl = json.glb_url;
|
| 151 |
const plyUrl = json.ply_url;
|
| 152 |
|
|
|
|
| 170 |
console.error("Full error details:", error);
|
| 171 |
return {
|
| 172 |
status: "error",
|
| 173 |
+
error: error instanceof Error ? error.message : String(error)
|
|
|
|
|
|
|
|
|
|
| 174 |
};
|
| 175 |
}
|
| 176 |
}
|
app.py
CHANGED
|
@@ -663,7 +663,7 @@ class Base64Request(BaseModel):
|
|
| 663 |
fastapi_app = block.app
|
| 664 |
|
| 665 |
|
| 666 |
-
@fastapi_app.post("/
|
| 667 |
async def api_base64_endpoint(req: Base64Request):
|
| 668 |
"""
|
| 669 |
FastAPI endpoint that accepts base64-encoded images and returns
|
|
|
|
| 663 |
fastapi_app = block.app
|
| 664 |
|
| 665 |
|
| 666 |
+
@fastapi_app.post("/base64")
|
| 667 |
async def api_base64_endpoint(req: Base64Request):
|
| 668 |
"""
|
| 669 |
FastAPI endpoint that accepts base64-encoded images and returns
|