Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Dash应用程序未在gunicorn nginx wsgi服务器上运行_Python 3.x_Nginx_Flask_Gunicorn_Plotly Dash - Fatal编程技术网

Python 3.x Dash应用程序未在gunicorn nginx wsgi服务器上运行

Python 3.x Dash应用程序未在gunicorn nginx wsgi服务器上运行,python-3.x,nginx,flask,gunicorn,plotly-dash,Python 3.x,Nginx,Flask,Gunicorn,Plotly Dash,我在Flask框架中为我的数据开发了一个dash应用程序。代码正在本地服务器上运行。但是,当我通过配置Nginx服务器在生产环境中使用Gunicorn wsgi来运行它时,我并没有得到任何结果 项目目录如下所示: flask_application | static |- | templates |- home.html | app.py | wsgi.py 我正在使用Putty连接的Centos7 ssh。下面是我试图在wsgi服务器上执行的代码以

我在Flask框架中为我的数据开发了一个dash应用程序。代码正在本地服务器上运行。但是,当我通过配置Nginx服务器在生产环境中使用Gunicorn wsgi来运行它时,我并没有得到任何结果

项目目录如下所示:

flask_application
   | static
     |-
   | templates
     |- home.html
   | app.py
   | wsgi.py
我正在使用Putty连接的Centos7 ssh。下面是我试图在wsgi服务器上执行的代码以及用于运行应用程序的命令

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
from flask import Flask, render_template
import pandas as pd

server = Flask(__name__)
app = dash.Dash(__name__, server=server)

@app.route("/")
def home_conf():
    return render_template("home.html")


df= pd.read_csv('my_dataframe.csv')
df= df[1:]
features = df.columns
df_types= features[1:] #don't want the Customer column


app.layout = html.Div([
    html.Div([
    #Here is the interactive component
        html.Div([
            dcc.Dropdown(
                id='yaxis',
                options=[{'label':i,'value':i} for i in 
df_types],
            value='df-type'
        )
    ], style={'width': '60%'})
]),
html.Div([dcc.Graph(
    id='df-graphic',
    figure={
        'data': [go.Scatter(
            x=df['Lender'],
            y=[0,0],
            mode='markers'
        )],
        'layout': go.Layout(
            title = 'Use the dropdown to display the chart ...',
            xaxis={'tickformat': 'd'}
        )
    }
    )
], style={'width':'70%', 'display':'inline-block'}),
html.Div([dcc.Graph(
    id='df-stacked',
    figure={
        'data': [go.Bar(
            x=df['Lender'],
            y=df['Login'],
            name='Login'
            ),
            go.Bar(
                            x=df['Lender'],
                            y=df['Approved'],
                            name='Approved'
                            ),
            go.Bar(
                            x=df['Lender'],
                            y=df['Reject'],
                            name='Reject'
                            ),
            go.Bar(
                            x=df['Lender'],
                            y=df['Agreement'],
                            name='Agreement'
                            ),
            go.Bar(
                            x=df['Lender'],
                            y=df['Disbursed'],
                            name='Disbursed'
                            ),
            go.Bar(
                            x=df['Lender'],
                            y=df['Cancelled'],
                            name='Cancelled'
                            ),
        ],
        'layout': go.Layout(
            title ='Customer Count in the finance from August, 2019',
            barmode='stack'
        )
    }
    )
], style={'width':'70%', 'display':'inline-block'}),
html.Div([dcc.Graph(
    id='df-boxplot',
    figure={
        'data': [go.Box(
        y=df['Login'],
        name='Login'
        ),
        go.Box(
                    y=df['Approved'],
                    name='Approved'
                    ),
        go.Box(
                    y=df['Reject'],
                    name='Reject'
                    ),
        go.Box(
                    y=df['Agreement'],
                    name='Agreement'
                    ),
        go.Box(
                    y=df['Disbursed'],
                    name='Disbursed'
                    ),
        go.Box(
                    y=df['Cancelled'],
                    name='Cancelled'
                    ),
        ],
        'layout': go.Layout(
        title='Customer Count in the Finance, August 2019'
        )
    }
)
], style={'width':'70%', 'display':'inline-block'}),
html.Div([
    dcc.Markdown(children=markdown_text)
])
], style={'padding':10})

#Here is the callback
@app.callback(
    Output('df-graphic', 'figure'),
    [Input ('yaxis', 'value')])
def update_graphic(yaxis_lbit):
    return {
        'data': [go.Scatter(
            x=df['Lender'],
            y=df[yaxis_lbit],
            mode='lines+markers',
            marker={
                'size': 15,
                'opacity': 0.5,
                'line': {'width':0.5, 'color':'white'}
            }
        )],
        'layout': go.Layout(
            title='{} in the Finance by Customer Count, 
 August 2019'.format(yaxis_lbit),
        xaxis={'title': 'Lender'},
        yaxis={'title': yaxis_lbit},
        hovermode='closest'
    )
}


if __name__ == '__main__':
    app.run_server(host='0.0.0.0', debug=True)
以下是连接到centos ssh后在WSGi中运行应用程序时使用的命令

gunicorn app:app

有人能解释为什么我在wsgi服务器中执行后没有得到结果,以及代码中需要做哪些更改吗。任何帮助都将不胜感激。谢谢。

您正在flask服务器内运行dash应用程序。 尝试gunicorn应用程序:服务器 同样,您应该更改“if mean”语句