Skip to content

Commit dfe1757

Browse files
authored
do not go to flexgen if post failed (#1375)
* do not go to flexgen if post failed * what
1 parent 70636fc commit dfe1757

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pcweb/pages/landing/views/hero.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@ async def redirect_to_ai_builder(self, form_data: dict):
3737
random_uuid = uuid.uuid4()
3838

3939
async with httpx.AsyncClient() as client:
40-
await client.post(
40+
response = await client.post(
4141
RX_BUILD_BACKEND.rstrip("/") + "/prompt",
4242
json={
43-
"prompt": prompt_map[prompt],
43+
"prompt": prompt_map.get(prompt, prompt),
4444
"token": str(random_uuid),
4545
"images": self.image_data_uris,
4646
},
4747
)
4848
async with self:
4949
self.reset()
50-
return rx.redirect(
51-
REFLEX_BUILD_URL.strip("/") + f"/prompt?token={random_uuid!s}"
50+
return (
51+
rx.redirect("/")
52+
if not response.is_success
53+
else rx.redirect(
54+
REFLEX_BUILD_URL.strip("/") + f"/prompt?token={random_uuid!s}"
55+
)
5256
)
5357

5458
@rx.event

0 commit comments

Comments
 (0)