From eb93917bdbb702c49fa8faff955a37e88326b916 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Sat, 27 Jul 2024 02:05:20 +0530 Subject: [PATCH] return the X-GOOEY-GUI-ROUTE header from gui.route --- gooey_ui/state.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gooey_ui/state.py b/gooey_ui/state.py index f53858c0b..011b9fa13 100644 --- a/gooey_ui/state.py +++ b/gooey_ui/state.py @@ -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, @@ -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