-
Notifications
You must be signed in to change notification settings - Fork 1
/
flask_app.py
59 lines (45 loc) · 1.39 KB
/
flask_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from flask import Flask, render_template
from flask_navigation import Navigation
import sqlite3
import os
import json
import pandas as pd
import plotly
import plotly.express as px
import plotly.graph_objects as go
app = Flask(__name__)
nav = Navigation(app)
# initializing Navigations
nav.Bar('top', [
nav.Item('Home', 'table'),
nav.Item('Insights', 'image'),
nav.Item('Interactive', 'chart')
])
def get_db_connection():
conn = sqlite3.connect('./database.db')
conn.row_factory = sqlite3.Row
return conn
@app.route('/')
def index():
return render_template('layout.html', title="Index")
@app.route('/table')
def table():
conn = get_db_connection()
games = conn.execute('SELECT * FROM Steam_game1').fetchall()
conn.close()
return render_template('table.html', games=games)
@app.route('/image')
def image():
return render_template('image.html')
@app.route('/chart')
def chart():
# Graph One
df = pd.read_csv("Dataset/clean_data.csv")
labels = df['platforms'].unique()
values = df['platforms'].value_counts()
fig = go.Figure(data=[go.Pie(labels=labels, values=values)])
graph1JSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
return render_template('index1.html', title="home", graph1JSON=graph1JSON)
if __name__ == '__main__':
port = os.environ.get("PORT")
app.run(debug=True,host = '0.0.0.0',port=port)