首页 > 解决方案 > 为什么 Dash 应用程序无法在 AWS Cloud9 中预览?

问题描述

尝试在 AWS Cloud9 中查看 Dash 应用程序。在 Cloud9 文档 ( https://docs.c9.io/docs/run-an-application ) 中,IP 需要为 0.0.0.0,并且唯一开放的端口是 8000、8001 和 8002。

在 run_server 函数中设置这些端口,并尝试将 adhoc ssl 与 pyopenssl 一起使用,但无济于事。

我正在从终端的 python 3.6 虚拟环境中运行该文件。

import dash
import dash_core_components as dcc
import dash_html_components as html

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

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': 'Montreal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])


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

我仍然无法在 Cloud9 的预览窗格中查看 Dash 应用程序。

有谁知道这个问题的解决方案?

标签: amazon-web-servicesflaskconfigurationplotly-dashaws-cloud9

解决方案


AWS Cloud9 的预览端口不同:8080、8081、8082。

有关更多信息,请参阅此文档 https://docs.aws.amazon.com/cloud9/latest/user-guide/app-preview.html


推荐阅读