-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
37 lines (29 loc) · 1.08 KB
/
server.py
File metadata and controls
37 lines (29 loc) · 1.08 KB
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
from flask import Flask, render_template, request
import RatingCharts
from Imdb import Imdb
app = Flask(__name__)
@app.route('/')
@app.route('/home')
@app.route('/search')
@app.route('/chart')
def home():
if request.args.get('search') is None:
search = None
else:
search = str(request.args.get('search')).strip()
scale = False
if request.args.get('scale') is not None:
if str(request.args.get('scale')) == 'True':
scale = bool(request.args.get('scale'))
if search is not None:
try:
true_title, episodes = RatingCharts.getEpisodes(Imdb(), search)
try:
chart_div = RatingCharts.buildChart(true_title, episodes, scale)
except:
return "Unable to build chart for \"" + search + "\""
except:
return "Unable to scrape episode data for \"" + search + "\""
return render_template('index.html', chart_div = chart_div, title = true_title)
else:
return render_template('index.html', chart_div = "", title = "Visualize TV Ratings")