InvalidConfig:`routes_pathname_prefix` 需要在登录页面以 `/` 结尾

问题描述

我正在尝试使用 Flask 在 dash 中为我的仪表板应用程序创建一个登录页面

我正在尝试运行此代码,但出现此错误

请告诉我该怎么做以及如何解决错误

# -*- 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,'y': [2,4,5],'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 相同的值结尾。

只需在末尾添加“/”即可。它是您使用的版本中的标准。 enter link description here

app = Dash(name='app1',url_base_pathname='/app1/',server=server)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...