【发布时间】:2020-04-15 17:56:23
【问题描述】:
这个问题建立在我关于 dash 集成的 previous question 之上。
问题:
当使用flask_wtf 模块激活 CSRF 时,如何在不因缺少 csrf 令牌而阻止 Dash 帖子的情况下集成 Dash 模块?
MWE:
from flask import Flask, request, render template
from flask_wtf.csrf import CSRFProtect
from dash import Dash
from dash.dependencies import Input, Output
app = Flask(__name__)
csrf = CSRFProtect(app)
app.config['SECRET_KEY'] = 'somethignrandom'
dapp = Dash(__name__, server=app, routes_pathname_prefix='/dash/')
dapp.layout = layoutfunction # this is left for your imagination
@app.route('/', methods=['GET','POST'])
def helloworld():
return render_template('index.html')
@app.route('/dash')
def dashing():
dapp.layout = layoutfunction
if __name__ == '__main__':
app.run(debug=True)
每当加载 /dash 时都会返回 404 错误。
【问题讨论】:
标签: python flask csrf plotly-dash