-
Notifications
You must be signed in to change notification settings - Fork 3
/
controller.py
127 lines (99 loc) · 6.59 KB
/
controller.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!usr/bin/env python3
import random
from datetime import datetime
import model as m
from flask import Flask, render_template, request, redirect, session, url_for
app = Flask(__name__)
app.secret_key = 'daniel is cool'
HUMANIZE_USE_UTC = True
@app.route('/',methods=['GET'])
@app.route('/menu',methods=['GET'])
def menu():
if request.method=="GET":
return render_template('menu.html')
else:
return render_template('menu.html')
@app.route('/weather', methods=['GET','POST'])
def weather():
if request.method=="GET":
return render_template('weather.html')
elif request.method=="POST":
submitted_city = request.form['city']
check_valid_city = m.check_status_code(submitted_city)
if check_valid_city == True:
session['submitted_city'] = submitted_city
return redirect('/outfits')
else:
return redirect('/weather')
@app.route('/outfits', methods=['GET','POST'])
def outfits():
if request.method=="GET":
submitted_city = session.get('submitted_city', None)
result = m.getWeather(submitted_city)
random.seed(datetime.now())
random_num = random.randint(0, 4)
cold_footwear = ["Boots", "Hiking Boots", "Uggs", "Winter Moccasins", "Leather Shoes"]
cold_top = ["Jacket", "Parka", "Overcoat", "Jacket Shell", "Fur Coat"]
cold_accessories = ["Hat", "Toque", "Mittens", "Gloves", "Scarf", "Thermal Base Layers"]
cold_bottoms = ["Jeans", "Sweatpants", "Leggings", "Jeggings", "Khakis"]
mild_footwear = ["Running Shoes", "Dress Shoes", "Slip-On Casual Shoes", "Slides", "Heels"]
mild_top = ["T-Shirt", "Long-Sleeve Shirt", "Light Sweatshirt", "Jean Jacket", "Dress Shirt"]
mild_accessories = ["Baseball Cap", "Headband", "Parasol", "Bucket Hat", "Watch"]
mild_bottoms = ["Sweatpants", "Long Skirt", "Jeans", "Cargo Pants", "Dress Pants", "Leggings"]
hot_footwear = ["Flip-Flops", "Sandals", "Slides", "Running Shoes", "Slip-On Casual Shoes"]
hot_top = ["Tank Top", "T-Shirt", "Undershirt", "Polo", "Blouse"]
hot_accessories = ["Fan", "Water Bottle", "Sunscreen", "Parasol", "Sunglasses"]
hot_bottoms = ["Short Skirt", "Cargo Shorts", "Jean Shorts", "Trackpants", "Athletic Shorts"]
jackets = ["Jacket", "Parka", "Overcoat", "Jacket Shell", "Jean Jacket"]
t_shirt = ["T-Shirt", "Tank Top", "Undershirt", "Polo"]
long_sleeve_shirt = ["Long-Sleeve Shirt", "Light Sweatshirt", "Dress Shirt", "Blouse"]
boots = ["Boots", "Hiking Boots", "Uggs", "Leather Shoes"]
joggers = ["Running Shoes", "Slip-On Casual Shoes"]
sandals = ["Slides", "Flip-Flops", "Sandals"]
miscellanouse_shoes = ["Winter Moccasins", "Dress Shoes"]
full_length = ["Jeans", "Sweatpants", "Khakis", "Long Skirt", "Cargo Pants", "Dress Pants"]
half_length = ["Short Skirt", "Cargo Shorts", "Jean Shorts", "Athletic Shorts"]
weather = ["Thunderstorm", "Drizzle", "Rain", "Snow", "Atmosphere", "Clear", "Clouds"]
return render_template('outfits.html', city = submitted_city, result = result, randomInt = random_num, coldFootwear = cold_footwear,
coldBottoms = cold_bottoms, coldTop = cold_top, coldAccessories = cold_accessories,
mildFootwear = mild_footwear, mildTop = mild_top, mildAccessories = mild_accessories, mildBottoms = mild_bottoms,
hotFootwear = hot_footwear, hotTop = hot_top, hotAccessories = hot_accessories, hotBottoms = hot_bottoms,
jacketsIcon = jackets, tShirtIcon = t_shirt, longSleeveIcon = long_sleeve_shirt, bootsIcon = boots,
joggersIcon = joggers, sandalsIcon = sandals, miscShoes = miscellanouse_shoes, weather = weather, longPants = full_length,
shortPants = half_length)
else:
submitted_city = session.get('submitted_city', None)
result = m.getWeather(submitted_city)
random.seed(datetime.now())
random_num = random.randint(0, 4)
cold_footwear = ["Boots", "Hiking Boots", "Uggs", "Winter Moccasins", "Leather Shoes"]
cold_top = ["Jacket", "Parka", "Overcoat", "Jacket Shell", "Fur Coat"]
cold_accessories = ["Scarf", "Thermal Base Layers"]
cold_bottoms = ["Jeans", "Sweatpants", "Leggings", "Jeggings", "Khakis"]
mild_footwear = ["Running Shoes", "Dress Shoes", "Slip-On Casual Shoes", "Slides", "Heels"]
mild_top = ["T-Shirt", "Long-Sleeve Shirt", "Light Sweatshirt", "Jean Jacket", "Dress Shirt"]
mild_accessories = ["Baseball Cap", "Headband", "Bucket Hat", "Watch"]
mild_bottoms = ["Sweatpants", "Long Skirt", "Jeans", "Cargo Pants", "Dress Pants", "Leggings"]
hot_footwear = ["Flip-Flops", "Sandals", "Slides", "Running Shoes", "Slip-On Casual Shoes"]
hot_top = ["Tank Top", "T-Shirt", "Undershirt", "Polo", "Blouse"]
hot_accessories = ["Fan", "Water Bottle", "Sunscreen", "Sunglasses"]
hot_bottoms = ["Short Skirt", "Cargo Shorts", "Jean Shorts", "Trackpants", "Athletic Shorts"]
jackets = ["Jacket", "Parka", "Overcoat", "Jacket Shell", "Fur Coat", "Jean Jacket"]
t_shirt = ["T-Shirt", "Tank Top", "Undershirt", "Polo"]
long_sleeve_shirt = ["Long-Sleeve Shirt", "Light Sweatshirt", "Dress Shirt", "Blouse"]
boots = ["Boots", "Hiking Boots", "Uggs", "Leather Shoes"]
joggers = ["Running Shoes", "Slip-On Casual Shoes"]
sandals = ["Slides", "Flip-Flops", "Sandals"]
miscellanouse_shoes = ["Winter Moccasins", "Dress Shoes", "Heels"]
full_length = ["Jeans", "Sweatpants", "Leggings", "Jeggings", "Khakis", "Long Skirt", "Cargo Pants", "Dress Pants", "Trackpants"]
half_length = ["Short Skirt", "Cargo Shorts", "Jean Shorts", "Athletic Shorts"]
weather = ["Thunderstorm", "Drizzle", "Rain", "Snow", "Atmosphere", "Clear", "Clouds"]
return render_template('outfits.html', city = submitted_city, result = result, randomInt = random_num, coldFootwear = cold_footwear,
coldBottoms = cold_bottoms, coldTop = cold_top, coldAccessories = cold_accessories,
mildFootwear = mild_footwear, mildTop = mild_top, mildAccessories = mild_accessories, mildBottoms = mild_bottoms,
hotFootwear = hot_footwear, hotTop = hot_top, hotAccessories = hot_accessories, hotBottoms = hot_bottoms,
jacketsIcon = jackets, tShirtIcon = t_shirt, longSleeveIcon = long_sleeve_shirt, bootsIcon = boots,
joggersIcon = joggers, sandalsIcon = sandals, miscShoes = miscellanouse_shoes, halfBottomsIcon = half_length,
fullBottomsIcon = full_length, weather = weather)
if __name__ == '__main__':
app.run(debug=True)