mic3333 commited on
Commit
1d76c68
·
verified ·
1 Parent(s): 0582d47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dash import Dash, html, dcc, callback, Output, Input
2
+ import plotly.express as px
3
+ import pandas as pd
4
+ import os
5
+
6
+ df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv')
7
+ app = Dash(__name__)
8
+ server = app.server # Important for deployment
9
+
10
+ app.layout = [
11
+ html.H1(children='Title of Dash App', style={'textAlign':'center'}),
12
+ dcc.Dropdown(df.country.unique(), 'Canada', id='dropdown-selection'),
13
+ dcc.Graph(id='graph-content')
14
+ ]
15
+
16
+ @callback(
17
+ Output('graph-content', 'figure'),
18
+ Input('dropdown-selection', 'value')
19
+ )
20
+ def update_graph(value):
21
+ dff = df[df.country==value]
22
+ return px.line(dff, x='year', y='pop')
23
+
24
+ if __name__ == '__main__':
25
+ port = int(os.environ.get('PORT', 7860))
26
+ app.run(host='0.0.0.0', port=port, debug=False)