-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
77 lines (67 loc) · 2.38 KB
/
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from flask import Flask, render_template, session, request
from flask import redirect, url_for
import api
import datetime
app = Flask(__name__)
thresh = 12
temp = -273 #temperature in celcius. If abs 0, then err
zipc = ""
genre = ""
rating = ""
@app.route("/", methods = ['GET','POST'])
def index():
'''
Routes the home page
return template html dummy
'''
if request.method == 'POST':
global zipc
zipc = request.form['zipcode']
global genre
genre = request.form['genre']
global rating
rating = request.form['rating']
global temp
temp = api.weather(zipc)
if temp == -1000:
return render_template("dummy.html")
elif temp >= thresh:
return redirect("/nochill")
else:
return redirect("/chill")
d = datetime.datetime.now()
date = d.strftime('%m-%d-%Y')
return render_template("dummy.html",date=date)
@app.route("/chill")
def chill():
'''
Routes the chill page, which is displayed if temperature is lower than 15 celsius, also accounts for genre and rating
Shows the list of movies available in amazon prime
return template html chill
'''
links = []
movies = api.amazon()
if genre != 'no':
movies = api.filterGenre(movies, genre)
if rating != 'no':
movies = api.filterRating(movies, rating)
for movie in movies:
links.append(api.amazonPurchase(movie['id']))
return render_template("chill.html", movies=movies, temp=temp, links=links)
@app.route("/nochill")
def nochill():
'''
Routes the nochill page which is displayed if temperature is higher than 15 degrees
Shows the list of movies in nearby theaters
return template html nochill
'''
movies = api.showtimes(zipc)
if genre != 'no':
movies = api.filterGenre(movies, genre)
if rating != 'no':
movies = api.filterRating(movies, rating)
return render_template("nochill.html", movies=movies, temp=temp)
if __name__ == "__main__":
app.secret_key = "hello"
app.debug = True
app.run(host='0.0.0.0', port=8000)