Skip to content

Commit

Permalink
return the X-GOOEY-GUI-ROUTE header from gui.route
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Jul 26, 2024
1 parent d146dca commit eb93917
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions gooey_ui/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from functools import wraps, partial

from fastapi import Depends
from fastapi.encoders import jsonable_encoder
from pydantic import BaseModel
from starlette.requests import Request
from starlette.responses import Response, RedirectResponse
from starlette.responses import Response, RedirectResponse, JSONResponse

from gooey_ui.pubsub import (
get_subscriptions,
Expand Down Expand Up @@ -148,11 +149,16 @@ def runner(
return RedirectResponse(e.url, status_code=e.status_code)
if isinstance(ret, Response):
return ret
return dict(
children=root.children,
state=get_session_state(),
channels=get_subscriptions(),
**(ret or {}),
return JSONResponse(
jsonable_encoder(
dict(
children=root.children,
state=get_session_state(),
channels=get_subscriptions(),
**(ret or {}),
)
),
headers={"X-GOOEY-GUI-ROUTE": "1"},
)
except RerunException:
continue
Expand Down

0 comments on commit eb93917

Please sign in to comment.