-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
346 lines (315 loc) · 10 KB
/
server.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
from dataclasses import dataclass
from flask import Flask
from flask import render_template
from flask import Response, request, jsonify
app = Flask(__name__)
import sys
user_answers = {
"question1":{
'overall': 0, #0 indicates wrong, 1 indicates correct
'answers': [],
},
"question2":{
'overall': 0,
'answers': [],
},
"question3":{
'overall': 0,
'answers': [],
},
"question4":{
'overall': 0,
'answers': [],
},
"question5":{
'overall': 0,
'answers': [],
},
}
lessons = [
{
"id": "0",
"text": "Advance through the lessons to learn the principles of color theory for fashion. On each page, hover over the images to learn more.",
},
{
"id": "1",
"text": "The neutral colors are black, white, grey, navy, beige, brown, and olive green. Neutrals make life easy and all go well together.",
"examples": [
{
"description": "British designer Phoebe Philo combines the neutrals beige, black, and white into a simple yet put-together look.",
"image": "/static/images/p1phoebe.png",
},
{
"description": "Although sometimes seen as a faux pas, black and navy here create a serious, composed outfit.",
"image": "/static/images/p1navy.png",
},
{
"description": "A seminal figure in the crossover between music and haute couture, Kanye here goes for rich browns, blacks, and olive greens.",
"image": "/static/images/p1kanye.png",
},
],
},
{
"id": "2",
"text": "A great wardrobe can be composed entirely of neutrals",
"examples": [
{
"description": "A sample men's wardrobe, primarily consisting of black and navy.",
"image": "/static/images/p2men.png",
},
{
"description": "A sample women's wardrobe, with more beiges and whites.",
"image": "/static/images/p2women.png",
},
],
},
{
"id": "3",
"text": "On a color wheel, colors next to each other are called analogous colors. Analogous colors go very well together.",
"examples": [
{
"description": "Color wheel",
"image": "/static/images/p3wheel.png",
},
{
"description": "Jennifer Lopez in a Versace gown at the 2000 Grammy Awards. The analagous green-torquoise color pairing pops.",
"image": "/static/images/p3jlo.png",
},
{
"description": "British designer Alexa Chung in a split-tone red-and-pink dress.",
"image": "/static/images/p3alexa.png",
}
],
},
{
"id": "4",
"text": "When in doubt, pick a few neutral colors and a hint of a bright non-neutral.",
"examples": [
{
"description": "This outfit consits mostly of the neutrals beige and white, but adds a pop of pink footwear.",
"image": "/static/images/p4heels.png",
},
{
"description": "The neutrals navy and white create a balanced look on top of bright, eye-catching red loafers.",
"image": "/static/images/p4red.png",
},
{
"description": "Ryan Gosling adds a touch of flair to the traditional navy suit and black shoes with an orange-yellow knit shirt.",
"image": "/static/images/p4yellow.jpeg",
}
],
},
{
"id": "5",
"text": "Never be afraid of color.",
"examples": [
{
"description": "Rapper A$AP Rocky sports a daring pink Loewe tuxedo with a classic white shirt and sneakers at the 2019 pre-Grammys gala.",
"image": "/static/images/p5rocky.png",
},
{
"description": "Kanye performs in an all-red suit-and-sneaker combo at the 2010 VMAs.",
"image": "/static/images/p5kanye.png",
},
{
"description": "Zendaya wears a red-yellow-orange (analogous colors!) all-over-print Dolce & Gabbana ballgown at the 2017 Met Gala.",
"image": "/static/images/p5zendaya.png",
}
],
},
]
questions = [
{
"id": "0",
"text": "Put your knowledge to test!",
"images": [],
},
{
"id": "1",
"text": "Identify the neutrals",
"images": [
"black",
"#ff00ff",
"lightgrey",
"#ff9900",
"#e1c699", #beige
"#01ffff",
"#9900ff",
"#1c4587", #navy
],
"answer": [
"black",
"lightgrey",
"#e1c699",
"#1c4587"
]
},
{
"id": "2",
"text": "Identify one analogous color pair",
"images": [
"#00ba00", #green
"#ff0000", #red
"black", #black
"#ffa100", #orange
"#00b6d8", #teal
"#fffa00", #yellow
"#0025c2", #blue
"#980ec2", #purple
],
"answer":[
["#00ba00", "#fffa00",], #green and yellow
["#00ba00", "#0025c2"], #green and blue
["#ff0000", "#ffa100"], #red and orange
["#ff0000","#980ec2" ], #red and purple
["#ffa100","#fffa00"], #orange and yellow
["#00b6d8", "#0025c2"], #teal and blue
["#00b6d8", "#00ba00"], #teal and green
["#0025c2", "#980ec2"] #blue and purple
],
},
{
"id": "3",
"text": "Build an outfit with mainly neutrals and at most one color",
"images": [
{
"description": "white",
"image": "/static/images/q4beige.png",
"type": "accesory"
},
{
"description": "green",
"image": "/static/images/q3green.png",
"type": "top"
},
{
"description": "beige",
"image": "/static/images/q3beige.png",
"type": "top"
},
{
"description": "red",
"image": "/static/images/q3red.png",
"type": "accesory"
},
{
"description": "purple",
"image": "/static/images/q3purple.png",
"type": "bottom"
},
{
"description": "black",
"image": "/static/images/q3black.png",
"type": "bottom"
},
],
"answer": [
# these are the wrong colors
"red",
"purple",
"green"
]
},
{
"id": "4",
"text": "Build an outfit with one neutral and an analogous color pair",
"answer":[
["red","orange",],
["navy", "purple"],
["red", "purple"]
],
"images": [
{
"description": "red",
"image": "/static/images/q4red.png",
"type": "hat"
},
{
"description": "orange",
"image": "/static/images/q4orange.png",
"type": "top"
},
{
"description": "purple",
"image": "/static/images/q4purple.png",
"type": "top"
},
{
"description": "beige",
"image": "/static/images/q3white.png",
"type": "hat"
},
{
"description": "navy",
"image": "/static/images/q4navy.png",
"type": "bottom"
},
{
"description": "black",
"image": "/static/images/q4black.png",
"type": "bottom"
},
],
},
{
"id": "5",
"text": "Choose the outfit that you think uses color the best",
"images": [
{
"description": "black",
"image": "/static/images/q5black.webp",
},
{
"description": "yellow",
"image": "/static/images/q5yellow.jpeg",
},
{
"description": "white",
"image": "/static/images/q5white.jpeg",
},
{
"description": "pink",
"image": "/static/images/q5pink.png",
},
],
},
{
"id": "6",
"text": "Well done!",
"images": [],
"answer" : user_answers
},
]
# ROUTES
@app.route('/')
def render_welcome():
return render_template('welcome.html')
@app.route('/learn/<id>')
def render_learn(id):
global lessons
this_lesson = [x for x in lessons if x["id"] == id]
if len(this_lesson) == 0:
this_lesson.append(lessons[0])
return render_template("learn.html", data = this_lesson[0],next = int(this_lesson[0]["id"]) + 1, before = int(this_lesson[0]["id"])-1)
@app.route('/quiz/<id>')
def render_quiz(id):
global questions
this_question = [x for x in questions if x["id"] == id]
if len(this_question) == 0:
this_question.append(questions[0])
return render_template("quiz.html", data = this_question[0], next = int(this_question[0]["id"]) + 1)
@app.route('/quiz/save_answers', methods=['POST'])
def save_answers():
global user_answers
json_data = request.get_json()
id = json_data["id"]
overall = json_data["overall"]
answers = json_data["answers"]
answer = {
"overall": overall,
"answers": answers,
}
user_answers[id] = answer
return jsonify(user_answers=user_answers)
if __name__ == '__main__':
app.run(debug = True)