-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.py
43 lines (34 loc) · 907 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from flask import Flask, render_template
import json
import plotly
import pandas as pd
import numpy as np
import plotly.graph_objs as go
app = Flask(__name__)
app.debug = True
@app.route('/')
def index():
# Read in the Data via Pandas
df = pd.read_table("data/fruit.txt")
# Create the Plotly Data Structure
graph = dict(
data=[go.Bar(
x=df["fruit"],
y=df["count"]
)],
layout=dict(
title='Bar Plot',
yaxis=dict(
title="Count"
),
xaxis=dict(
title="Fruit"
)
)
)
# Convert the figures to JSON
graphJSON = json.dumps(graph, cls=plotly.utils.PlotlyJSONEncoder)
# Render the Template
return render_template('layouts/index.html', graphJSON=graphJSON)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9999)