- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 plotly dash 应用程序,我想将它放在受 JWT 保护的路线后面。我的最终目标是将其包含在单独路线上的 iframe 中,但我只希望用户能够在他们有访问 token 的情况下获取 dash 应用程序的 html。
我已重试在获取请求中返回应用程序本身。
应用程序.py
import dash
from flask import Flask, jsonify, request
from flask_jwt_extended import (
JWTManager, jwt_required, create_access_token,
get_jwt_identity
)
server = Flask(__name__)
server.config['JWT_SECRET_KEY'] = 'super-secret' # Change this!
jwt = JWTManager(server)
@server.route('/login', methods=['POST'])
def login():
if not request.is_json:
return jsonify({"msg": "Missing JSON in request"}), 400
username = request.json.get('username', None)
password = request.json.get('password', None)
if not username:
return jsonify({"msg": "Missing username parameter"}), 400
if not password:
return jsonify({"msg": "Missing password parameter"}), 400
if username != 'test' or password != 'test':
return jsonify({"msg": "Bad username or password"}), 401
# Identity can be any data that is json serializable
access_token = create_access_token(identity=username)
return jsonify(access_token=access_token), 200
@server.route('/')
@jwt_required
def index():
return 'Hello world flask app'
app = dash.Dash(
__name__,
server=server,
routes_pathname_prefix='/'
)
app.config.suppress_callback_exceptions = True
from app import app
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
from combination_1 import Combination
import callbacks
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id="root_div")
])
@app.callback(
Output('root_div', 'children'),
[Input('url', 'pathname')]
)
def attatch_graphs(pathname):
return Combination(comb_id='comb_1').return_div()
if __name__ == '__main__':
app.run_server()
最佳答案
我将分享一些我在研究这个问题时发现的资源:
dash-auth
,您可以使用 pip install dash-auth
进行安装import dash_auth
,您会注意到 HTTP Basic Auth 的子模块, OAuth和“PlotlyAuth”。根据 from dash_auth.plotly_auth import deprecation_notice
中的文字,“PlotlyAuth”已被弃用Response.set_cookie
进行集成. Here are details about that approach ,请注意作者使用rep.set_cookie('custom-auth-session', username)
关于python - 如何将 Plotly dash 应用程序放在 protected 路线后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57629586/
Mpeg 短跑流媒体 我正在写关于直播的论文。我使用带有 rtmp 模块的 ffmpeg,ngix 服务器和来自 Dash industry 的 dash.js .我通过 ffmpeg 开始流到服务器
我正在创建一个播放静态 mpeg-DASH 文件的应用程序。我一直在使用 MP4Box 创建 DASH .mp4 和 .mpd 文件。 MPD 文件包含单个 .mp4 文件中的字节范围偏移列表。这工作
当从任何一个下拉列表中选择任何选项时,我希望从所有其他下拉列表中删除相同的选项。 为了帮助形象化这一点,我正在尝试构建一个列映射器。对于左侧的每个列名,右侧都有一个下拉列表,用户可以在其中从他们上传的
我正在尝试为不同的信息集创建一个具有多个选项卡的应用程序。我的第一个想法是使用 html 按钮,但没有 dash_core_component 用于此,而且我找不到任何可以在其位置使用的文档。基本上,
请建议我如何在 dashing 应用程序中显示图像(在引用使用 dashing.io rubygem 创建的应用程序中) 最佳答案 使用图像小部件: 请注意,路径 /logo.png 指
我发现 Core Graphics 想要的字体名称与 UIFont 接受的不同。 例如,CG 接受“Helvetica Bold”但不接受“Helvetica-Bold”,而 UIFont 则相反。
我已将 dash 应用程序连接到 AWS RDS。我有一个实时更新的图表,它触发一个 n_interval 为 5 分钟的回调来查询数据库并进行一些昂贵的格式化。我将转换后的数据(约 500 个数据点
我对 Dash Plotly 很陌生,我正试图弄清楚如何设计这样的布局。 Layout : 据我了解,使用 dash bootstrap 组件可以更轻松地完成此操作。 https://dash-boo
我已经构建了一个仪表板并使用我自己的 css 自定义了外观。该应用程序的结构如下 然后我对我们的 linux 服务器进行了docker化和部署。不幸的是,我们的 linux 服务器用它自己的 css
戒指dash_daq.Gauge输出太薄,如下图所示。 我想要更厚的戒指。我在'inspect element'下找不到css元素来增加环的厚度。我该怎么做? 最佳答案 只需创建一个 assets 文
是否可以在图表底部有一个文本字段,以破折号显示它们所在点的文本(将悬停数据显示为纯文本)。因此,当用户将鼠标悬停在某个点上时,文本框将能够进行更改。我已经定义了一个 dcc.Graph 组件和应用程序
我正在尝试运行此 Dash 教程 https://github.com/cryptopotluck/alpha_vantage_tutorial/tree/master/dash_bootstrap/
作为 Dash 的初学者,我有一个简单的问题。我正在使用一个表来接受用户输入,读入它,最终对其执行一个操作,然后在第一个下面返回一个结果表。下面是我的代码: import dash import da
我正在尝试通过 macOS 上的 Jupiter notebook 运行 dash。它确实被导入,当我尝试运行 app.run_server 命令时它失败了。它给了我以下错误 [Errno 8] no
我遇到了 Plotly Dash 的问题,即由 dcc.Store 组件触发的回调每次触发两次。请参阅下面的代码和示例输出代码,它基于 Dash 文档 ( https://dash.plot.ly/d
我正在使用 dash 应用程序调用包含 351 列的大约 250,000 个值的大型数据集,以便我可以显示它。然而,它需要很长时间才能运行,我认为这是因为我从一个不同的应用程序调用数据,我用来收集名为
我正在更新一些代码以使用 Dash 和plotly。绘图的主要代码是在类中定义的。我用 Dash 控件替换了一些 Bokeh 小部件,最终得到了如下所示的回调: class MakeStuff:
我正在尝试实现用于播放受 widevine 保护的视频的 Android 应用程序。我在 Exoplayer 上构建我的应用程序,但我遇到了 MediaDrm 问题。 android.media.Me
你可以在这里看到实现: http://jsfiddle.net/Wtcdt/ 在 Mac 上的 FireFox 中,该圆圈是圆形/实心的。我想要它是虚线还是点线。 更奇怪的是,相同的属性(即 bord
我看GPUImage2的源码 picture = PictureInput(image:UIImage(named:"WID-small.jpg")!) filter = Satura
我是一名优秀的程序员,十分优秀!