-
-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No query_params, session_args or FastAPI Query Params #7338
Comments
No pn.state.session_argsI see the same problem when using import panel as pn
from fastapi import FastAPI
from panel.io.fastapi import add_application
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@add_application("/panel", app=app, title="My Panel App")
def create_panel_app():
slider = pn.widgets.IntSlider(name="Slider", start=0, end=10, value=3)
return pn.Column(
pn.state.location.query_params,
pn.state.session_args,
slider.rx() * "⭐",
) |
No FastAPI Query ParametersAccording to https://fastapi.tiangolo.com/tutorial/query-params/ the query-params should be additional keywords not in the path. But that does not work either import panel as pn
from fastapi import FastAPI
from panel.io.fastapi import add_application
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@add_application("/panel", app=app, title="My Panel App")
def create_panel_app(hello: str=""):
print(hello)
slider = pn.widgets.IntSlider(name="Slider", start=0, end=10, value=3)
return pn.Column(
pn.pane.Str(hello, styles={"border": "1px solid black"}),
slider.rx() * "⭐",
) |
This issue has been mentioned on HoloViz Discourse. There might be relevant details there: https://discourse.holoviz.org/t/how-to-access-query-params-when-running-panel-using-fastapi/8240/2 |
FYI. Syncing parameters works thoughYou can sync widget/parameter values to the url though import panel as pn
from fastapi import FastAPI
from panel.io.fastapi import add_application
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@add_application("/panel", app=app, title="My Panel App")
def create_panel_app():
widget = pn.widgets.FloatSlider(name='Slider', start=0, end=10)
widget2 = pn.widgets.TextInput(name='Text')
widget3 = pn.widgets.RangeSlider(name='RangeSlider', start=0, end=10)
if pn.state.location:
pn.state.location.sync(widget, {'value': 'slider_value'})
pn.state.location.sync(widget2, {'value': 'text_value'})
pn.state.location.sync(widget3, {'value': 'range_value'})
return pn.Column(widget, widget2, widget3) |
panel==1.5.1, bokeh-fastapi==0.1.0
No pn.state.location.query_params
In https://discourse.holoviz.org/t/how-to-access-query-params-when-running-panel-using-fastapi/8240 Makalai reports that
pn.state.location.query_params
is always empty when following https://panel.holoviz.org/how_to/integrations/FastAPI.html.I can reproduce this via
The text was updated successfully, but these errors were encountered: