This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
453 lines (357 loc) · 43.4 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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# ! /bin/python3
import os, re, sys
import models
from flask import *
import random
import datetime
from werkzeug.security import generate_password_hash, check_password_hash
from filter import search_handler
# imports with mangodb and flask and other stuff
recom = [[146, 251, 754, 713, 306], [251, 146, 754, 306, 818], [146, 251, 754, 713, 684], [146, 251, 754, 713, 818], [146, 251, 754, 713, 306], [713, 146, 754, 251, 306], [251, 146, 754, 684, 713], [251, 146, 754, 684, 306], [146, 251, 754, 684, 713], [146, 754, 251, 713, 818], [146, 251, 754, 713, 684], [251, 146, 754, 713, 818], [251, 146, 754, 713, 306], [251, 146, 754, 713, 818], [251, 146, 754, 818, 306], [146, 684, 754, 251, 713], [146, 251, 754, 713, 306], [146, 251, 754, 713, 306], [146, 251, 754, 713, 684], [684, 146, 754, 251, 713], [754, 251, 146, 713, 306], [251, 754, 146, 713, 715], [684, 146, 754, 251, 877], [251, 754, 146, 713, 306], [146, 754, 251, 713, 306], [146, 251, 754, 713, 306], [146, 754, 251, 684, 713], [251, 754, 146, 306, 818], [146, 251, 754, 713, 684], [251, 146, 754, 713, 818], [251, 146, 754, 684, 818], [251, 146, 754, 306, 818], [251, 754, 146, 818, 306], [251, 146, 754, 713, 306], [146, 754, 684, 251, 713], [146, 754, 251, 684, 818], [251, 146, 754, 713, 306], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [684, 251, 146, 754, 818], [146, 251, 754, 713, 818], [251, 146, 754, 684, 818], [251, 146, 754, 818, 306], [251, 146, 754, 713, 818], [684, 146, 754, 251, 877], [251, 146, 754, 713, 818], [684, 146, 754, 251, 713], [251, 146, 754, 713, 684], [251, 146, 754, 684, 818], [146, 754, 684, 251, 713], [146, 754, 251, 684, 818], [684, 146, 754, 251, 877], [684, 146, 754, 251, 713], [146, 754, 251, 713, 306], [146, 684, 754, 251, 713], [251, 754, 146, 713, 306], [251, 146, 754, 713, 306], [146, 251, 754, 713, 684], [146, 251, 754, 684, 818], [251, 754, 146, 818, 306], [251, 146, 754, 713, 306], [146, 754, 251, 713, 818], [146, 251, 754, 306, 818], [713, 754, 146, 251, 306], [251, 146, 754, 713, 306], [713, 146, 754, 251, 684], [251, 754, 146, 246, 713], [251, 754, 146, 713, 306], [146, 754, 251, 713, 306], [251, 754, 146, 713, 306], [251, 146, 754, 818, 306], [251, 146, 754, 306, 818], [251, 146, 754, 713, 306], [684, 146, 251, 754, 713], [251, 754, 146, 713, 306], [146, 251, 754, 684, 818], [251, 754, 146, 713, 306], [251, 146, 754, 713, 684], [146, 754, 251, 713, 306], [251, 146, 754, 66, 306], [251, 754, 146, 713, 306], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [684, 146, 754, 251, 877], [251, 146, 754, 684, 713], [251, 146, 754, 684, 306], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [146, 684, 251, 754, 877], [251, 146, 754, 306, 818], [251, 754, 146, 713, 818], [251, 754, 146, 162, 306], [251, 146, 754, 713, 818], [251, 146, 754, 684, 306], [251, 146, 754, 684, 818], [146, 754, 251, 306, 755], [146, 251, 754, 684, 713], [754, 251, 146, 713, 684], [146, 754, 251, 713, 684], [251, 146, 754, 306, 684], [251, 146, 754, 818, 684], [251, 146, 754, 684, 306], [251, 146, 754, 713, 684], [251, 146, 754, 713, 684], [754, 146, 251, 684, 713], [251, 146, 754, 684, 306], [146, 251, 754, 684, 306], [146, 754, 251, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 306, 818], [146, 251, 754, 713, 684], [146, 754, 251, 713, 684], [146, 754, 251, 713, 684], [146, 251, 754, 684, 713], [251, 146, 754, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 684, 713], [251, 146, 754, 713, 306], [146, 754, 251, 684, 713], [251, 146, 754, 684, 818], [684, 146, 754, 251, 713], [146, 754, 251, 684, 713], [251, 146, 754, 306, 818], [713, 754, 251, 146, 306], [146, 754, 251, 684, 713], [251, 146, 754, 818, 306], [146, 251, 754, 684, 713], [251, 754, 684, 146, 713], [146, 251, 754, 713, 684], [251, 146, 754, 684, 818], [146, 251, 754, 713, 306], [146, 251, 754, 684, 713], [251, 146, 754, 684, 818], [146, 251, 754, 684, 306], [251, 146, 754, 306, 818], [146, 251, 754, 684, 306], [251, 146, 754, 684, 818], [146, 251, 754, 684, 306], [146, 754, 251, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [146, 754, 251, 713, 684], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [146, 754, 251, 684, 713], [251, 713, 146, 754, 306], [146, 251, 754, 684, 713], [251, 146, 754, 713, 306], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [251, 754, 146, 818, 303], [251, 146, 754, 684, 713], [251, 146, 754, 162, 306], [251, 146, 754, 684, 306], [251, 146, 754, 684, 713], [251, 146, 754, 713, 818], [251, 146, 754, 713, 684], [251, 754, 146, 684, 306], [251, 146, 754, 713, 684], [146, 754, 251, 684, 713], [251, 754, 146, 713, 684], [146, 251, 754, 684, 306], [684, 146, 754, 251, 715], [146, 754, 251, 713, 684], [146, 754, 251, 684, 713], [251, 754, 146, 713, 306], [251, 146, 754, 684, 713], [251, 146, 754, 684, 818], [146, 251, 754, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 713, 818], [251, 146, 754, 306, 818], [251, 754, 146, 818, 306], [146, 251, 754, 684, 713], [251, 146, 754, 684, 713], [146, 251, 754, 684, 306], [251, 754, 146, 713, 306], [146, 251, 754, 713, 684], [146, 251, 754, 684, 818], [251, 754, 146, 713, 306], [754, 251, 146, 684, 306], [251, 146, 754, 713, 684], [146, 754, 251, 713, 684], [146, 754, 251, 713, 306], [146, 251, 754, 713, 684], [251, 754, 146, 713, 276], [251, 146, 754, 684, 306], [251, 146, 754, 684, 306], [146, 251, 754, 713, 684], [713, 146, 754, 684, 251], [146, 251, 754, 684, 713], [251, 754, 146, 713, 684], [146, 754, 251, 684, 713], [251, 146, 754, 684, 713], [146, 754, 251, 713, 684], [251, 754, 146, 713, 276], [146, 754, 251, 684, 713], [146, 754, 251, 684, 713], [754, 146, 251, 713, 64], [251, 146, 754, 713, 306], [251, 754, 146, 713, 684], [251, 146, 754, 684, 713], [146, 251, 754, 684, 818], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [251, 146, 754, 684, 306], [251, 146, 754, 713, 684], [251, 146, 754, 684, 713], [251, 146, 754, 684, 713], [146, 251, 754, 713, 684], [251, 754, 146, 713, 684], [754, 146, 251, 713, 684], [146, 251, 754, 713, 306], [251, 146, 754, 306, 818], [146, 251, 754, 684, 306], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [146, 754, 251, 713, 684], [146, 754, 251, 713, 684], [251, 146, 754, 684, 713], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 684, 713], [251, 146, 754, 713, 684], [146, 251, 754, 684, 818], [146, 754, 251, 713, 684], [146, 251, 754, 684, 306], [146, 251, 754, 713, 684], [251, 146, 754, 684, 306], [146, 251, 754, 713, 684], [146, 251, 754, 684, 306], [146, 251, 754, 713, 684], [251, 146, 754, 713, 684], [251, 146, 754, 713, 306], [146, 251, 754, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 684, 818], [251, 146, 754, 684, 713], [251, 146, 754, 684, 713], [251, 146, 754, 713, 684], [251, 146, 754, 306, 818], [146, 754, 251, 684, 818], [146, 754, 251, 713, 684], [251, 146, 754, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 684, 818], [146, 754, 251, 713, 684], [251, 146, 754, 306, 818], [146, 251, 754, 713, 684], [251, 146, 754, 306, 818], [251, 146, 754, 713, 684], [251, 146, 754, 684, 818], [684, 146, 754, 251, 713], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [251, 146, 754, 684, 818], [146, 251, 754, 684, 306], [146, 251, 754, 713, 306], [251, 146, 754, 684, 713], [251, 146, 754, 684, 713], [251, 146, 754, 684, 818], [251, 754, 146, 713, 684], [251, 146, 754, 713, 306], [146, 754, 251, 684, 713], [146, 251, 754, 713, 684], [146, 754, 251, 684, 713], [251, 146, 754, 684, 306], [251, 146, 754, 684, 649], [251, 146, 754, 684, 713], [146, 251, 754, 713, 306], [754, 251, 146, 684, 818], [146, 754, 251, 818, 306], [146, 251, 754, 684, 713], [146, 251, 754, 684, 818], [146, 251, 754, 713, 684], [146, 754, 713, 251, 684], [754, 146, 251, 713, 306], [146, 251, 754, 684, 713], [251, 146, 754, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 306, 818], [146, 251, 754, 713, 684], [251, 146, 754, 684, 818], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 713, 818], [146, 251, 754, 713, 684], [146, 251, 754, 684, 818], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [251, 146, 754, 684, 306], [146, 251, 754, 306, 818], [251, 146, 754, 684, 306], [251, 754, 146, 713, 684], [146, 754, 251, 684, 818], [146, 754, 251, 684, 818], [251, 146, 754, 713, 306], [251, 146, 754, 818, 306], [251, 754, 146, 713, 306], [684, 146, 754, 251, 877], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [251, 754, 146, 684, 306], [754, 146, 251, 713, 818], [251, 146, 754, 713, 306], [251, 146, 754, 684, 818], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [146, 251, 754, 713, 306], [251, 146, 754, 684, 713], [146, 754, 251, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [146, 754, 251, 713, 818], [146, 754, 251, 684, 713], [251, 146, 754, 713, 306], [146, 251, 754, 713, 684], [754, 146, 251, 713, 684], [146, 754, 251, 755, 64], [251, 146, 754, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [713, 146, 754, 251, 684], [754, 146, 251, 713, 457], [146, 251, 754, 306, 818], [146, 251, 754, 684, 713], [251, 754, 146, 684, 306], [251, 146, 754, 713, 684], [146, 754, 251, 684, 713], [146, 754, 251, 713, 684], [251, 146, 754, 306, 818], [146, 251, 754, 684, 818], [251, 146, 754, 713, 306], [251, 754, 146, 713, 684], [146, 754, 251, 713, 684], [146, 754, 251, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 713, 818], [251, 754, 146, 713, 818], [146, 251, 754, 684, 306], [251, 754, 146, 713, 306], [146, 754, 251, 684, 713], [146, 251, 754, 684, 818], [146, 251, 754, 684, 713], [146, 251, 754, 684, 713], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [251, 754, 146, 713, 818], [146, 754, 251, 684, 713], [146, 754, 251, 713, 684], [251, 146, 754, 713, 684], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [251, 146, 754, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 713, 684], [146, 251, 754, 684, 713], [146, 251, 754, 684, 713], [251, 754, 146, 713, 684], [251, 754, 146, 818, 306], [684, 146, 754, 251, 877], [251, 146, 754, 713, 684], [251, 146, 754, 684, 713], [146, 251, 754, 306, 818], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [251, 146, 754, 713, 306], [251, 754, 146, 713, 306], [146, 251, 754, 713, 306], [146, 251, 754, 684, 713], [251, 713, 754, 146, 658], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [251, 754, 146, 818, 306], [146, 251, 754, 713, 684], [251, 754, 146, 306, 818], [251, 146, 754, 684, 306], [251, 146, 754, 818, 306], [146, 251, 713, 754, 306], [146, 251, 684, 754, 713], [146, 251, 684, 754, 713], [146, 251, 754, 684, 713], [251, 146, 754, 713, 306], [754, 251, 146, 713, 818], [146, 251, 754, 684, 713], [754, 146, 251, 713, 818], [146, 251, 754, 684, 713], [754, 146, 251, 713, 818], [754, 251, 146, 713, 684], [146, 251, 754, 684, 713], [754, 251, 146, 713, 818], [146, 251, 754, 684, 713], [251, 754, 146, 713, 818], [251, 754, 146, 306, 772], [251, 754, 146, 818, 306], [251, 146, 754, 684, 306], [146, 251, 684, 754, 877], [754, 146, 713, 251, 684], [146, 251, 754, 713, 684], [146, 754, 251, 684, 713], [146, 251, 754, 684, 818], [251, 146, 754, 306, 818], [251, 754, 146, 713, 306], [251, 146, 754, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 713, 684], [146, 251, 754, 713, 306], [251, 146, 754, 684, 818], [146, 754, 251, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [146, 754, 251, 713, 684], [251, 146, 754, 713, 818], [251, 754, 146, 713, 818], [251, 754, 146, 684, 818], [146, 754, 251, 684, 457], [146, 754, 251, 684, 877], [251, 146, 754, 684, 818], [251, 146, 754, 684, 306], [251, 754, 146, 306, 818], [146, 754, 251, 713, 306], [146, 754, 251, 713, 684], [146, 754, 251, 684, 713], [251, 754, 146, 684, 713], [251, 146, 754, 306, 818], [251, 146, 754, 684, 713], [146, 251, 754, 684, 818], [146, 251, 754, 684, 818], [251, 146, 754, 306, 818], [146, 754, 251, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 713, 818], [251, 146, 754, 713, 818], [146, 251, 754, 713, 306], [251, 146, 754, 306, 818], [146, 251, 754, 684, 306], [754, 146, 251, 713, 306], [754, 146, 251, 713, 818], [251, 754, 146, 713, 818], [251, 754, 146, 818, 306], [146, 251, 754, 684, 713], [684, 146, 754, 251, 877], [146, 754, 251, 684, 713], [146, 251, 754, 713, 306], [146, 754, 251, 713, 818], [146, 754, 251, 713, 684], [251, 146, 754, 684, 713], [251, 754, 146, 684, 818], [684, 251, 146, 754, 713], [251, 146, 713, 754, 684], [146, 754, 251, 684, 713], [146, 251, 754, 684, 818], [251, 146, 754, 713, 684], [251, 146, 754, 684, 818], [146, 754, 251, 713, 684], [146, 251, 754, 713, 306], [146, 754, 251, 684, 713], [251, 146, 754, 818, 457], [146, 251, 754, 684, 818], [146, 754, 251, 713, 684], [146, 251, 754, 713, 684], [146, 754, 251, 684, 713], [251, 146, 754, 713, 684], [251, 146, 754, 713, 306], [146, 754, 251, 684, 306], [251, 146, 754, 713, 684], [251, 754, 146, 713, 818], [251, 146, 754, 684, 713], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [251, 146, 754, 306, 818], [146, 251, 754, 684, 713], [146, 754, 251, 684, 713], [251, 146, 754, 684, 818], [251, 146, 754, 684, 713], [754, 146, 251, 684, 306], [251, 146, 754, 684, 818], [251, 146, 754, 306, 276], [146, 754, 251, 713, 684], [146, 251, 754, 684, 818], [251, 754, 146, 713, 684], [684, 146, 251, 754, 877], [251, 146, 754, 684, 818], [713, 146, 754, 251, 684], [251, 754, 146, 276, 306], [251, 146, 754, 684, 818], [251, 146, 754, 684, 713], [251, 146, 754, 713, 306], [713, 146, 754, 684, 251], [251, 754, 146, 684, 818], [251, 146, 754, 684, 306], [251, 754, 146, 306, 818], [146, 754, 251, 713, 684], [146, 251, 754, 684, 306], [251, 146, 754, 684, 818], [146, 251, 754, 306, 818], [251, 754, 146, 713, 818], [251, 146, 754, 306, 818], [251, 146, 754, 306, 713], [251, 146, 754, 684, 818], [146, 754, 251, 684, 818], [251, 146, 754, 713, 306], [713, 146, 251, 754, 192], [251, 146, 754, 684, 306], [251, 146, 754, 684, 818], [146, 251, 754, 684, 818], [713, 146, 754, 251, 306], [251, 146, 754, 684, 818], [146, 251, 754, 684, 818], [146, 754, 251, 684, 818], [251, 754, 146, 684, 818], [251, 754, 146, 306, 818], [146, 713, 754, 684, 251], [251, 146, 754, 684, 818], [251, 754, 146, 684, 818], [146, 684, 754, 251, 713], [251, 146, 754, 684, 818], [146, 754, 251, 684, 818], [251, 146, 754, 684, 713], [251, 146, 754, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 818, 306], [251, 754, 146, 684, 818], [251, 146, 754, 684, 306], [146, 251, 754, 684, 818], [146, 251, 754, 684, 306], [251, 146, 754, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 684, 818], [754, 146, 251, 684, 818], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [146, 754, 251, 306, 818], [146, 754, 713, 251, 684], [146, 754, 251, 713, 684], [251, 146, 754, 306, 818], [251, 146, 754, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 684, 713], [713, 146, 754, 251, 306], [146, 754, 251, 684, 713], [146, 251, 754, 713, 306], [146, 754, 251, 818, 306], [251, 146, 754, 684, 818], [713, 146, 754, 251, 306], [146, 251, 754, 713, 684], [251, 146, 754, 818, 306], [251, 146, 754, 684, 818], [713, 146, 754, 251, 684], [713, 146, 754, 251, 684], [713, 754, 146, 251, 684], [713, 146, 754, 251, 684], [146, 754, 251, 713, 684], [146, 754, 684, 251, 306], [146, 251, 754, 713, 684], [146, 754, 251, 684, 713], [146, 754, 251, 713, 457], [146, 251, 754, 684, 713], [251, 146, 754, 818, 306], [146, 251, 754, 684, 713], [146, 251, 754, 684, 306], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [146, 754, 251, 684, 713], [146, 754, 684, 251, 713], [251, 754, 146, 713, 684], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [754, 146, 251, 684, 713], [251, 754, 146, 306, 713], [146, 754, 251, 713, 684], [251, 146, 754, 713, 818], [146, 251, 754, 713, 306], [146, 754, 251, 713, 684], [251, 146, 754, 713, 306], [146, 754, 251, 713, 306], [251, 146, 754, 684, 713], [146, 251, 754, 306, 818], [251, 146, 754, 684, 713], [146, 251, 754, 684, 713], [251, 754, 146, 713, 306], [251, 754, 146, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [146, 251, 754, 684, 306], [146, 713, 754, 684, 251], [146, 251, 754, 684, 713], [146, 251, 754, 684, 713], [146, 251, 754, 684, 713], [146, 754, 251, 713, 684], [684, 146, 754, 251, 877], [251, 754, 146, 684, 818], [251, 754, 146, 818, 306], [251, 146, 754, 684, 306], [713, 146, 754, 251, 684], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 684, 713], [146, 754, 251, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 684, 713], [754, 251, 146, 713, 306], [146, 251, 754, 713, 684], [251, 146, 754, 713, 684], [754, 146, 251, 684, 713], [754, 146, 251, 713, 306], [684, 713, 146, 754, 251], [251, 146, 754, 713, 772], [251, 146, 754, 713, 684], [251, 146, 754, 684, 306], [146, 754, 251, 684, 818], [146, 251, 754, 306, 684], [146, 754, 251, 684, 306], [251, 146, 754, 713, 684], [146, 754, 251, 713, 684], [146, 251, 754, 713, 306], [251, 146, 754, 684, 713], [251, 146, 754, 713, 684], [251, 754, 146, 713, 306], [251, 146, 754, 684, 713], [251, 146, 754, 684, 818], [754, 251, 146, 713, 684], [251, 146, 754, 713, 306], [251, 754, 146, 713, 818], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 713, 818], [251, 754, 146, 162, 818], [146, 251, 754, 684, 818], [146, 251, 754, 684, 713], [251, 146, 754, 684, 713], [146, 754, 713, 251, 684], [251, 146, 754, 713, 306], [146, 754, 251, 684, 713], [251, 146, 754, 306, 818], [146, 251, 754, 684, 306], [251, 754, 146, 713, 684], [754, 251, 146, 713, 306], [251, 146, 754, 684, 306], [146, 251, 754, 713, 684], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [146, 251, 754, 684, 713], [146, 754, 251, 713, 684], [146, 754, 251, 684, 713], [146, 754, 251, 713, 684], [146, 754, 251, 713, 818], [146, 754, 251, 684, 713], [251, 146, 754, 713, 684], [251, 754, 146, 713, 306], [251, 146, 754, 713, 306], [251, 146, 754, 713, 818], [251, 754, 146, 684, 306], [146, 251, 754, 713, 684], [146, 251, 754, 713, 306], [146, 251, 754, 684, 818], [146, 754, 251, 684, 818], [251, 146, 754, 713, 684], [251, 754, 146, 684, 306], [251, 146, 754, 684, 713], [251, 146, 754, 684, 713], [251, 754, 146, 713, 684], [754, 251, 146, 713, 306], [146, 251, 754, 684, 713], [754, 146, 251, 713, 818], [251, 146, 754, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [251, 754, 146, 684, 713], [146, 251, 754, 684, 818], [146, 251, 754, 713, 306], [251, 754, 146, 684, 162], [251, 146, 754, 684, 818], [146, 754, 251, 713, 684], [146, 684, 754, 251, 713], [146, 251, 754, 818, 684], [251, 146, 754, 684, 713], [754, 251, 146, 684, 713], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [146, 251, 754, 684, 713], [146, 754, 251, 713, 306], [146, 754, 251, 684, 713], [251, 146, 754, 684, 713], [146, 251, 754, 713, 306], [251, 146, 754, 306, 684], [146, 754, 251, 684, 713], [251, 146, 754, 684, 818], [146, 251, 754, 684, 818], [251, 146, 754, 713, 306], [146, 754, 251, 713, 306], [146, 713, 754, 251, 684], [251, 754, 146, 684, 306], [754, 146, 251, 684, 713], [684, 146, 754, 251, 818], [251, 146, 754, 306, 818], [251, 146, 754, 684, 306], [251, 754, 146, 713, 306], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [251, 754, 146, 306, 713], [146, 251, 754, 306, 818], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [146, 754, 251, 713, 818], [251, 146, 754, 306, 684], [251, 146, 754, 684, 818], [146, 754, 251, 684, 818], [146, 251, 754, 684, 818], [146, 684, 251, 649, 818], [251, 146, 754, 713, 246], [146, 251, 754, 713, 306], [251, 146, 754, 684, 306], [251, 146, 754, 306, 818], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [146, 754, 251, 713, 684], [251, 146, 754, 684, 306], [251, 146, 754, 684, 306], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [146, 251, 754, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 684, 818], [684, 754, 146, 251, 713], [251, 146, 754, 713, 818], [146, 251, 754, 713, 684], [146, 251, 754, 713, 684], [146, 754, 251, 684, 713], [146, 251, 754, 713, 684], [146, 754, 251, 713, 306], [251, 146, 754, 684, 818], [146, 754, 251, 684, 713], [251, 146, 754, 684, 818], [146, 251, 754, 684, 818], [146, 251, 754, 306, 818], [146, 251, 754, 684, 713], [146, 754, 251, 684, 713], [251, 146, 754, 684, 713], [251, 146, 754, 684, 818], [146, 251, 754, 684, 818], [146, 251, 754, 684, 713], [251, 146, 754, 818, 306], [146, 251, 754, 684, 713], [251, 146, 754, 684, 818], [251, 754, 146, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 684, 713], [146, 251, 754, 713, 306], [251, 146, 754, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [146, 251, 754, 713, 306], [251, 146, 754, 713, 306], [146, 251, 754, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 713, 306], [251, 146, 754, 713, 306], [251, 146, 754, 684, 818], [146, 251, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [146, 251, 754, 713, 306], [146, 251, 754, 713, 306], [251, 146, 754, 713, 306], [146, 251, 754, 713, 306], [251, 146, 754, 713, 306], [146, 251, 684, 754, 818], [251, 146, 754, 684, 818], [251, 754, 146, 818, 306], [754, 146, 251, 684, 713], [754, 146, 251, 713, 684], [146, 754, 251, 684, 713], [754, 146, 251, 684, 713], [754, 146, 251, 684, 818], [146, 754, 251, 684, 713], [251, 146, 754, 684, 713], [146, 754, 251, 684, 713], [754, 146, 251, 684, 818], [754, 251, 146, 715, 306], [251, 754, 146, 684, 818], [251, 754, 146, 713, 684], [146, 754, 251, 684, 713], [146, 754, 251, 684, 713], [146, 754, 251, 713, 684], [146, 754, 251, 684, 818], [146, 684, 754, 251, 877], [251, 754, 146, 818, 770], [251, 146, 754, 684, 818], [146, 754, 251, 713, 306], [251, 754, 146, 684, 818], [251, 146, 754, 684, 818], [146, 754, 713, 251, 684], [146, 754, 251, 684, 713], [251, 754, 146, 684, 818], [251, 754, 146, 306, 818], [146, 684, 754, 713, 770], [146, 754, 684, 713, 715], [146, 754, 684, 713, 877], [251, 754, 146, 684, 818], [251, 754, 146, 713, 306], [251, 754, 146, 684, 818], [146, 754, 684, 713, 251], [146, 684, 754, 713, 877], [251, 754, 146, 684, 818], [146, 754, 684, 251, 713], [251, 754, 146, 818, 306], [251, 754, 146, 684, 818], [146, 754, 684, 713, 251], [146, 684, 754, 713, 715], [146, 754, 684, 713, 251], [251, 754, 146, 818, 306], [251, 754, 146, 713, 684], [146, 754, 251, 684, 713], [251, 146, 754, 306, 818], [251, 754, 146, 713, 306], [684, 251, 146, 754, 818], [146, 754, 713, 684, 251], [684, 251, 146, 754, 649], [146, 754, 713, 684, 877], [684, 146, 754, 713, 877], [251, 146, 754, 684, 713], [146, 754, 684, 713, 251], [146, 754, 251, 684, 713], [146, 754, 713, 684, 251], [251, 146, 754, 684, 306], [146, 754, 684, 713, 251], [251, 146, 754, 684, 306], [146, 684, 754, 713, 877], [251, 146, 754, 818, 306], [146, 754, 684, 713, 251], [146, 684, 754, 713, 877], [251, 146, 754, 306, 818], [146, 684, 754, 251, 713], [251, 754, 146, 713, 306], [251, 146, 754, 684, 818], [251, 754, 146, 713, 818], [251, 146, 754, 713, 306], [684, 251, 146, 754, 877], [251, 146, 754, 306, 818], [146, 251, 754, 684, 306], [251, 146, 754, 684, 818], [754, 146, 251, 713, 684], [146, 754, 251, 684, 713], [146, 754, 251, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 684, 818], [251, 754, 146, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 713, 684], [251, 146, 754, 713, 684], [146, 754, 251, 684, 818], [251, 146, 754, 684, 818], [146, 754, 251, 713, 306], [251, 754, 146, 713, 306], [146, 754, 251, 713, 684], [146, 251, 754, 713, 684], [146, 251, 754, 684, 818], [146, 251, 754, 684, 818], [251, 146, 754, 684, 818], [251, 146, 754, 713, 684], [146, 251, 754, 684, 306], [146, 251, 754, 684, 818], [251, 146, 754, 684, 818], [146, 251, 754, 684, 713], [146, 754, 251, 713, 684], [251, 146, 754, 684, 306], [251, 146, 754, 684, 715], [251, 146, 754, 684, 713], [251, 146, 754, 684, 713], [146, 754, 251, 684, 818], [146, 754, 251, 684, 713], [754, 251, 146, 713, 684], [684, 146, 754, 251, 713], [146, 754, 251, 684, 770], [146, 754, 251, 684, 306], [754, 251, 146, 684, 818], [754, 146, 251, 684, 713], [754, 251, 146, 684, 713], [251, 754, 146, 713, 684], [146, 754, 251, 713, 684], [146, 251, 754, 684, 713], [754, 146, 251, 684, 772], [146, 754, 251, 684, 818], [251, 754, 146, 684, 818], [146, 754, 251, 684, 715], [713, 146, 251, 754, 684], [251, 146, 754, 684, 713], [251, 146, 754, 713, 818], [251, 146, 754, 713, 818], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 684, 713], [146, 251, 754, 713, 684], [251, 146, 754, 306, 818], [251, 146, 754, 684, 713], [146, 754, 251, 684, 306], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 713, 306], [146, 251, 754, 713, 306], [251, 146, 754, 713, 457], [251, 146, 754, 306, 684], [146, 251, 754, 713, 684], [251, 146, 754, 713, 306], [684, 146, 251, 754, 877], [713, 146, 754, 251, 684], [251, 146, 754, 818, 306], [146, 251, 754, 713, 306], [251, 146, 754, 684, 306], [146, 754, 251, 684, 713], [251, 146, 754, 713, 306], [251, 146, 754, 684, 713], [251, 754, 146, 684, 818], [754, 251, 146, 684, 818], [146, 754, 251, 684, 306], [146, 754, 251, 684, 818], [754, 146, 251, 684, 713], [146, 754, 251, 684, 306], [146, 754, 251, 684, 818], [146, 754, 251, 684, 818], [251, 146, 754, 684, 713], [251, 146, 754, 684, 306], [146, 684, 251, 754, 877], [251, 754, 146, 713, 818], [251, 146, 754, 306, 818], [146, 251, 754, 684, 306], [146, 754, 251, 713, 818], [251, 146, 754, 306, 818], [251, 146, 754, 713, 684], [251, 146, 754, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 713, 818], [754, 146, 251, 713, 684], [251, 146, 754, 713, 818], [251, 146, 754, 713, 162], [251, 146, 754, 713, 306], [146, 251, 754, 818, 306], [146, 251, 754, 713, 306], [251, 754, 146, 713, 306], [251, 146, 754, 713, 684], [251, 754, 146, 713, 306], [146, 251, 754, 713, 306], [251, 146, 754, 713, 818], [146, 251, 754, 306, 818], [251, 754, 146, 306, 713], [146, 251, 754, 684, 713], [146, 251, 754, 684, 713], [251, 754, 146, 713, 306], [251, 146, 754, 713, 684], [146, 251, 754, 684, 713], [251, 146, 754, 684, 713], [754, 251, 146, 713, 684], [251, 754, 146, 818, 306], [146, 754, 251, 684, 306], [146, 754, 684, 251, 713], [251, 146, 754, 713, 818], [146, 251, 754, 684, 713], [251, 754, 146, 818, 713], [251, 146, 754, 713, 306], [146, 251, 754, 684, 306], [251, 146, 754, 713, 684], [146, 251, 754, 713, 306], [251, 754, 146, 713, 306], [251, 146, 754, 713, 306], [146, 754, 251, 713, 684], [251, 146, 754, 818, 306], [251, 146, 754, 713, 306], [146, 251, 754, 684, 306], [251, 146, 754, 713, 818]]
app = Flask(__name__, template_folder='templates')
UPLOAD_FOLDER = 'static/images'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# route for home page
@app.route('/', methods=['POST','GET'])
def homepage():
err = 0
if request.method == 'POST':
req = request.form.to_dict()
# print (req)
result = search_handler(req)
print("sa",result)
if result:
data = models.select_all(sorted(result, reverse=True))
print('a', data)
a= []
for i in data:
if len(i)>=1:
a.append(i)
data = a
img = get_img( [i[0][0] for i in data])
rate =models.group_by('distinct(property_id), round(avg(rating),1) as avrg',
'property_id order by property_id desc', 'reviews')
return render_template('homepage.html', data=data, img=img, len=len(img), rate= rate)
else:
err = "Search results not found, here are some other suggestions for you."
data = []
rate = []
for i in models.group_by('distinct(property_id), round(avg(rating),1) as avrg',
'property_id order by property_id desc', 'reviews'):
data.append(i[0])
rate.append(i[1])
print('b', data)
img = get_img(data)
data = models.select_all(data)
if session.get('logged_in'):
r = recom[random.randint(0,999)]
data2 = models.select_all(r)
print('c', data)
img2 = get_img(r)
rate2 = [i[0] for i in models.select('round(avg(rating),1) as avrg',
' property_id in '+str(tuple(r))+' group by property_id order by property_id desc', 'reviews')]
return render_template('homepage.html', data=data, data2= data2, img=img, img2=img2, len=len(data2), rate= rate2)
return render_template('homepage.html', data=data, img=img, len=len(data), err= err, rate= rate)
# route for posting ad
@app.route('/services', methods=['GET', 'POST'])
def services():
if not session.get('logged_in'):
return render_template('signin.html')
else:
if request.method == 'POST':
id = get_data(request.form.to_dict())
img = get_img([id])
return redirect(url_for('p_detail', prop_id=id, img=img,len= len(img)))
return render_template('services.html')
#get data from db
def get_data(req):
new = {}
k = []
for i in range(1,7):
if 'pic'+str(i) not in req.keys():
k.append('pic'+str(i))
new['facilities'] = [int(i) for i in request.form.getlist('facilities')]
new['amenities'] = [int(i) for i in request.form.getlist('amenities')]
new['rule'] = [int(i) for i in request.form.getlist('rule')]
l = []
for i in range(0,10):
if 'bedroom'+str(i) in req.keys():
if req['bedroom'+str(i)] != '':
l.append(req['bedroom'+str(i)])
l = sum([int(i) for i in l])
new['bednum'] = l
new['bath'] = req['quantity']
new['guest'] = req['quantity1']
new['address'] = req['address']
new['bedrooms'] = req['bedroom']
new['suburb'] = req['suburb']
new['postcode'] = req['poscode']
new['title'] = req['title']
now = datetime.datetime.now()
new['fromdate'] = '10/16/2018'
new['todate'] = '10/17/2018'
if req['atype'] == 'hotel':
new['atype'] = 'house'
new['sub_type'] = req['type-house']
else:
new['atype'] = 'apartment'
new['sub_type'] = req['type-apa']
new['price'] = req['price']
new['description'] = req['message']
id = models.insertUser('properties (title, property_type, property_subtype, summary, rules)',"'{}','{}','{}','{}','{}'".format(new['title'], new['atype'],new['sub_type'], new['description'],str(tuple(sorted(new['rule']))) ))
models.insertUser('properties_posted (property_id,user_id,property_status)',
"'{}','{}','{}'".format(id,session['user_id'], 'available'))
models.insertUser('room_details (property_id, bedrooms_num, bed_num, bathrooms_num, guest_num, from_date, to_date, cost)',
"'{}','{}','{}','{}','{}','{}','{}','{}'".format(id,new['bedrooms'],new['bednum'] , new['bath'], new['guest'] ,new['fromdate'], new['todate'], new['price'] ))
models.insertUser('accom_amenities (property_id, amenities_list)',"'{}','{}'".format(id,str(tuple(sorted(new['amenities']) ))))
models.insertUser('accom_facilities (property_id,facilities_list)', "'{}','{}'".format(id, str(tuple(sorted(new['facilities'])))))
models.insertUser('location_details (property_id,suburb,post_code, street)', "'{}','{}','{}','{}'".format(id,new['suburb'] ,new['postcode'],new['address']))
for i in k:
file = request.files[i]
f = os.path.join(app.config['UPLOAD_FOLDER'] + '/room_pics', file.filename)
models.insertUser('accom_photos (property_id, accom_photo)', "'{}','{}'".format(id, file.filename))
file.save(f)
return id
# route for search which calllers filter
@app.route('/search', methods=['GET', 'POST'])
def search():
if request.method == 'POST':
# print (req)
result = search_handler(request.form.to_dict())
data = models.select_all(result)
img = get_img(result)
if len(data):
return render_template('search.html', data =data, img=img,len= len(img))
return homepage()
# route for login
@app.route('/login', methods=['GET', 'POST'])
def login():
return render_template('signin.html')
@app.route('/signin', methods=['POST', 'GET'])
def signin():
# print(request.form.to_dict())
if request.form['email']== 'admin':
if request.form['password'] == 'admin':
return render_template('admin.html')
user_data= models.select('*','email_id==\''+request.form['email']+'\'','user_detail')[0]
# print(user_data)
if check_password_hash( user_data[2], request.form['password']):
session['logged_in'] = True
session['user_id'] = user_data[0]
session['booked'] = [i[0] for i in models.select("property_id","user_id ='{}' and status='booked'".format(user_data[0]),'visitor_property')]
session['saved'] = [i[0] for i in
models.select("property_id", "user_id ='{}' and status='saved'".format(user_data[0]), 'visitor_property')]
return profile(session['user_id'])
else:
flash('wrong password!')
return render_template('signin.html')
def get_img(id_list):
img_list = []
for i in id_list:
img_list.append(models.select('accom_photo', 'property_id ={}'.format(i), 'accom_photos'))
return img_list
@app.route('/accommodation', methods=['GET', 'POST'])
def accommodation():
if request.method:
data = [i[0] for i in models.select('distinct(property_id), rating', 'rating >= \'4.0\' order by rating desc', 'reviews')]
img = get_img(data)
data = models.select_all(data)
return render_template('accommodation.html', data=data, img = img, len=len(img))
@app.route('/detail/<int:prop_id>', methods=['GET','POST'])
def detail(prop_id):
d = models.select_all([prop_id])
d = list(d[0][0])
d[17] = d[17].replace('(','').replace(')','').split(',')
d[16] = d[16].replace('(', '').replace(')', '').split(',')
d[18] = d[18].replace('(', '').replace(')', '').split(',')
r = models.select('review, rating, name, user_pic', 'property_id =\''+str(prop_id)+'\'', 'reviews natural join user_detail')
img = [i[0] for i in get_img([prop_id])[0]]
# print(img)
if session.get('logged_in'):
if prop_id in session['booked']:
session['status'] = 'booked'
elif prop_id in session['saved']:
session['status'] = 'saved'
else:
session['status'] = ''
return render_template('detail.html', data=d, img = img, reviews= r, l=len(img), err='booked')
# post_detail.html
@app.route('/p_detail/<int:prop_id>', methods=['GET','POST'])
def p_detail(prop_id):
d = models.select_all([prop_id])
d = list(d[0][0])
d[17] = d[17].replace('(','').replace(')','').split(',')
d[16] = d[16].replace('(', '').replace(')', '').split(',')
d[18] = d[18].replace('(', '').replace(')', '').split(',')
r = models.select('review, rating, name, user_pic', 'property_id =\''+str(prop_id)+'\'', 'reviews natural join user_detail')
img = [i[0] for i in get_img([prop_id])[0]]
# print(img)
return render_template('post_detail.html', data=d, img = img, reviews= r, l=len(img))
# post_detail.html
@app.route('/review', methods=['GET'])
def review():
if request.method == 'GET':
id = request.args.to_dict()['id']
return render_template('review.html', id = id)
@app.route('/review/<int:id>', methods=['GET','POST'])
def rev(id):
if request.method == 'POST':
r = request.form.to_dict()
models.insertUser('reviews (property_id, user_id,review, rating)', "'{}','{}','{}','{}'".format(id, session['user_id'], r['message'], r['rate']))
return profile(session['user_id'])
@app.route('/view',methods=['GET'])
def view():
id = request.args.to_dict()
return detail(id)
@app.route('/book/<int:id>', methods=['GET', 'POST'])
def book(id):
if request.method == 'POST':
if session.get('logged_in'):
if request.form['book'] == 'BOOK':
a = request.form['datetimes']
a1 = datetime.date(datetime.datetime.now().year, int(a.split(' ')[0].split('/')[0]),
int(a.split(' ')[0].split('/')[1]))
a2 = datetime.date(datetime.datetime.now().year, int(a.split(' ')[4].split('/')[0]),
int(a.split(' ')[4].split('/')[1]))
d = models.select('status', "property_id='{}'".format(id), 'visitor_property')
if not d:
c = "'{}','{}','{}','{}','{}','{}'".format(session['user_id'], id, 'booked',
request.form['datetimes'],
int(request.form['quantity']) + int(
request.form['quantity1']),
abs((a1 - a2).days) * 200)
models.insertUser('visitor_property', c)
models.update('properties_posted', "property_status='{}'".format('booked'),
"property_id = '{}'".format(id))
session['status'] = 'booked'
session['booked'].append(id)
# print(session['booked'])
return redirect(url_for('detail', prop_id=id))
elif d=='saved':
session['status'] = 'booked'
session['booked'].append(id)
# print(session['booked'])
models.update('visitor_property', "user_id ='{}', status='{}',date ='{}', quantity='{}', cost_paid={}".format(session['user_id'],'booked', request.form['datetimes'],int(request.form['quantity']) + int(request.form['quantity1']), abs((a1 - a2).days) * 200), "property_id='{}'".format(id))
if request.form['book'] == 'SAVE':
c = "'{}','{}','{}','{}','{}','{}'".format(session['user_id'], id, 'saved', request.form['datetimes'],'','')
models.insertUser('visitor_property', c)
session['status'] = 'saved'
session['saved'].append(id)
return redirect(url_for('detail', prop_id=id))
else:
return login()
return redirect(url_for('detail', prop_id = id))
@app.route('/contact',methods=['GET', 'POST'])
def contact():
if request.method=='POST':
r = request.form.to_dict()
models.insertUser('messages_table (to_email,from_email,message)',"'{}','{}','{}'".format('admin',r['email'],r['message']))
return render_template('contact.html')
return render_template('contact.html')
def check_if_exist(email):
data = models.select('user_id','email_id =\''+email+'\'','user_detail')
if(data):
return True
else:
return False
@app.route('/signup', methods=['GET', 'POST'])
def signup():
error = []
if request.method == 'POST':
# print(request.form.to_dict())
if 5<len(request.form['name'])<30:
name = request.form['name']
else:
error.append('Insert Valid Name')
if len(request.form['email']) > 7:
if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$",
request.form['email']) != None:
if not (check_if_exist(request.form['email'])):
email = request.form['email']
else:
error.append("Email Id exists")
else:
error.append("Insert Valid Email Address")
else:
error.append("Insert Valid Email Address")
if re.match("^[0-9]{9,11}$", request.form['phone']) != None:
phone = request.form['phone']
else:
error.append("Insert Valid Phone Number")
if (40 > len(request.form['password1']) > 8):
if request.form['password1'] != request.form['password2']:
error.append("Password does not match")
else:
pas = request.form['password1']
else:
error.append("Password must contain more than 8 characters ")
if len(error)>0:
# print(error)
return render_template('signup.html', error=error)
else:
models.insertUser("user_detail ('name', 'password','email_id', 'phone', 'user_intro')", "'{}','{}','{}','{}','{}'".format(name, generate_password_hash(pas), email, phone,request.form['description'] ))
return redirect(url_for('login'))
else:
return render_template('signup.html')
# return render_template('signup.html')
@app.route('/err', methods=['POST', 'GET'])
def err():
if request.method:
return render_template('signup.html')
@app.route('/upload', methods=['POST'])
def upload_file():
file = request.files['image']
f = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
file.save(f)
return render_template('a.html')
@app.route('/profile/<int:id>', methods=['POST', 'GET'])
def profile(id):
user_data = list(models.select('*', 'user_id==\'' + str(id) + '\'', 'user_detail')[0])
trans = check_booking(id)
booked = []
saved = []
for i in trans:
if i[4] =='booked':
booked.append(i)
elif i[4] == 'saved':
saved.append(i)
trans2 = check_hosting(id)
# print(trans2)
return render_template('setting.html', user_data=user_data, booked=booked, saved= saved, hosted= trans2)
def check_booking(id):
data = models.select('property_id, title, date, cost_paid, status', 'user_id==\'' + str(id) + '\'', 'properties natural join visitor_property')
return data
def check_hosting(id):
data = models.select('*', 'user_id==\'' + str(id) + '\'', 'properties natural join properties_posted natural join room_details')
return data
@app.route('/edit_profile/<int:id>', methods=['POST', 'GET'])
def edit_profile(id):
# print(request.form.to_dict())
user_data = list(models.select('*', 'user_id==\'' + str(id) + '\'', 'user_detail')[0])
user_data[0] = str(user_data[0])
if request.form['first_name']!='':
models.update('user_detail', 'name =\''+request.form['first_name']+'\'', 'user_id =\''+user_data[0]+'\'' )
if request.form['email'] !='':
models.update('user_detail', 'email_id =\'' + request.form['email']+'\'', 'user_id =\'' + user_data[0] + '\'')
if request.form['mobile'] != '':
models.update('user_detail', 'phone =\'' + request.form['mobile']+'\'', 'user_id =\'' + user_data[0] + '\'')
if request.form['password'] != '':
if request.form['password'] == request.form['confirmpwd']:
models.update('user_detail', 'password =\'' + generate_password_hash(request.form['password'])+'\'', 'user_id =\'' + user_data[0] + '\'')
logout()
if request.form['description'] !='':
models.update('user_detail', 'user_intro =\'' + request.form['description']+'\'', 'user_id =\'' + str(user_data[0]) + '\'')
if request.files['profile_pic']:
file = request.files['profile_pic']
f = os.path.join(app.config['UPLOAD_FOLDER']+'/user_pics', file.filename)
models.update('user_detail', 'user_pic =\'' + file.filename + '\'',
'user_id =\'' + user_data[0] + '\'')
file.save(f)
return render_template('setting.html',user_data= user_data)
@app.route('/logout', methods=['POST', 'GET'])
def logout():
session['logged_in'] = False
return render_template('signin.html')
if __name__ == '__main__':
app.secret_key = os.urandom(12)
app.run(debug = "ON", host='0.0.0.0', port='5000' )