python - InvalidConfig:`routes_pathname_prefix` 需要在登录页面以 `/` 结尾
问题描述
我正在尝试使用烧瓶在破折号中为我的仪表板应用程序创建一个登录页面
我正在尝试运行此代码,但出现此错误。
请告诉我应该做什么以及如何解决此错误
# -*- coding: utf-8 -*-
import os
from flask import Flask
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash import Dash
from dash_flask_login import FlaskLoginAuth
import sqlite3
import hashlib
from flask_login import UserMixin
# Setup the Flask server
server = Flask(__name__)
# config
server.config.update(
SECRET_KEY = os.urandom(12),
)
# Create our initial Dash App
app = Dash(name='app1', url_base_pathname='/app1', server=server)
auth = FlaskLoginAuth(app, use_default_views=True)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''
Dash: A web application framework for Python.
'''),
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
),
html.A(dcc.Input(value='Log Out', type='submit'), href='/logout', )
])
app.css.append_css({
'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css',
})
# Run the server
if __name__ == '__main__':
server.run(debug=True, port=8050)
解决方案
requests_pathname_prefix
必须以routes_pathname_prefix
. 如果您在此更新之前同时提供了请求和路由路径名,请确保 requests_pathname_prefix 以与routes_pathname_prefix
.
只需在末尾添加“/”即可。它是您使用的版本中的标准。 在此处输入链接描述
app = Dash(name='app1', url_base_pathname='/app1/', server=server)
推荐阅读
- javascript - 组合 2 个不同长度的数组,重复较短的数组以匹配较长数组的长度
- kubernetes - 当我放置 2 条路径时,使用 nginx 入口控制器的入口不起作用
- kubernetes - Spring Cloud 数据流日志级别
- python - Pandas - 合并较小的类别
- visual-studio-code - 如何在 VSC 中获取 html 建议格式?
- c++ - 在间隔内运行函数,同时运行主代码
- javascript - if-else 无法清除列表或在列表已清除时发出警报
- javascript - 源更改时图片不更改
- javascript - 在 JavaScript 中使用逻辑与三元运算符的具体案例
- python - Pytorch 计算批次级别预测的命中率