12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
编程知识 时间:2024-12-05 09:49:59
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
要获取Plotly应用程序的缓存URL,您可以使用dash_clientside模块中的app.get_relative_path函数来获取相对路径,然后将其与应用程序的基本URL连接起来。以下是获取应用程序缓存
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
要获取Plotly应用程序的缓存URL,您可以使用dash_clientside
模块中的app.get_relative_path
函数来获取相对路径,然后将其与应用程序的基本URL连接起来。以下是获取应用程序缓存URL的示例代码:
from dash import Dash, htmlfrom dash_clientside import clientsideapp = Dash(__name__)app.layout = html.Div([html.Button('Click me', id='button'),html.Div(id='output')])@app.callback(clientside.callback("""function(pathname) {return pathname}""",Output('output', 'children'),[Input('button', 'n_clicks')],prevent_initial_call=True))def update_output(n_clicks):if n_clicks:pathname = app.get_relative_path()cache_url = app.config.requests_pathname_prefix + pathnamereturn cache_urlif __name__ == '__main__':app.run_server(debug=True)
在这个例子中,我们设置了一个按钮,当按钮被点击时,会触发一个回调函数update_output
,该函数获取当前页面的相对路径,并连接到应用程序的基本URL上,最终返回一个缓存URL。您可以根据需要修改这段代码,以适应您的具体需求。
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19