首页 > 移动平台 > 详细

使用dash和python创建app示例

时间:2021-02-01 11:57:50      阅读:35      评论:0      收藏:0      [点我收藏+]

本帖参考: https://blog.csdn.net/charizard90/article/details/105232590

Dash是一款用来搭建Web应用的Python框架,基于Flask,Plotly,js和React。
Dash的官网是https://dash.plotly.com/。
Dash的安装非常简单,直接通过pip install dash就能安装完成。

技术分享图片

根据官网教程创建一个app.py。

# -*- coding: utf-8 -*-
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‘: u‘Montréal‘},
            ],
            ‘layout‘: {
                ‘title‘: ‘Dash Data Visualization‘
            }
        }
    )
])

if __name__ == ‘__main__‘:
    app.run_server(debug=True)

运行python app.py
在浏览器中访问http://127.0.0.1:8050,第一个Dash应用就成功创建了。

技术分享图片

使用dash和python创建app示例

原文:https://www.cnblogs.com/E-Dreamer-Blogs/p/14355556.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!