除了本地主机以外,从外部访问破折号

时间:2018-09-13 12:51:18

标签: flask plotly-dash

我正在测试一个简单的破折号应用程序,该应用程序已从一个入门示例中进行了修改。我可以从运行应用程序的计算机访问仪表板,但无法在其他任何地方访问它。这是程序。

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import flask

df = pd.read_csv(
    'https://gist.githubusercontent.com/chriddyp/'
    'c78bf172206ce24f77d6363a2d754b59/raw/'
    'c353e8ef842413cae56ae3920b8fd78468aa4cb2/'
    'usa-agricultural-exports-2011.csv')


def generate_table(dataframe, max_rows=10):
    return html.Table(
        # Header
        [html.Tr([html.Th(col) for col in dataframe.columns])] +

        # Body
        [html.Tr([
            html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
        ]) for i in range(min(len(dataframe), max_rows))]
    )

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

app.layout = html.Div(children=[
    html.H4(children='US Agriculture Exports (2011)'),
    generate_table(df)
])

if __name__ == '__main__':
    app.run_server(host="0.0.0.0",port=8050)

0 个答案:

没有答案