-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.py
More file actions
78 lines (66 loc) · 2.8 KB
/
Home.py
File metadata and controls
78 lines (66 loc) · 2.8 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
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
import os
from flask import Flask, render_template, make_response, request
import Common.common
from Games.DuetsGame import duets_game, duets_game_
from Games.GameManager import game_conclusion
from Games.PairsGame import pairs_game, pairs_game_
from Games.RankByCountryGame import rank_by_country_game, rank_by_country_game_
from Games.ReleaseOrderGame import release_order_game, release_order_game_
from Games.TranslationGame import translate_game, translate_game_
from Games.WordInSongs import word_in_songs, word_in_songs_
from Pages.Authentication import log_in, sign_up, log_out, new_pass
from Pages.GameSelection import game_selection
from Pages.Highscores import highscores, highscores_ranking_by_country, highscores_who_sang_with_who, highscores_pairs_matching, highscores_word_in_commom, highscores_translation, \
highscores_release_order
from Pages.Bonus import bonus
from gevent.wsgi import WSGIServer
app = Flask(__name__)
app.register_blueprint(bonus)
app.register_blueprint(game_selection)
app.register_blueprint(game_conclusion)
app.register_blueprint(highscores)
app.register_blueprint(highscores_ranking_by_country)
app.register_blueprint(highscores_who_sang_with_who)
app.register_blueprint(highscores_pairs_matching)
app.register_blueprint(highscores_word_in_commom)
app.register_blueprint(highscores_translation)
app.register_blueprint(highscores_release_order)
app.register_blueprint(release_order_game)
app.register_blueprint(release_order_game_)
app.register_blueprint(translate_game)
app.register_blueprint(translate_game_)
app.register_blueprint(duets_game)
app.register_blueprint(duets_game_)
app.register_blueprint(pairs_game)
app.register_blueprint(pairs_game_)
app.register_blueprint(rank_by_country_game)
app.register_blueprint(rank_by_country_game_)
app.register_blueprint(log_in)
app.register_blueprint(sign_up)
app.register_blueprint(log_out)
app.register_blueprint(new_pass)
app.register_blueprint(word_in_songs)
app.register_blueprint(word_in_songs_)
app.secret_key = os.urandom(12)
@app.route('/')
def create_home_page():
nickname = Common.common.get_value_from_cookie(request, 'nickname')
user_logon = ''
if nickname is not None:
user_logon = 'true'
user_score = Common.common.get_value_from_cookie(request, 'score')
if user_score is None:
user_score = 0
if float(user_score) > 500 and nickname is not None:
get_bonus = 'true'
else:
get_bonus = ''
response = make_response(render_template('home.html', nickname=nickname, user_logon=user_logon, score=user_score, bonus=get_bonus))
return response
# Show a custom page in case of a 404 error.
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
if __name__ == '__main__':
http_server = WSGIServer(('0.0.0.0', 40557), app)
http_server.serve_forever()