-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainScores.py
75 lines (71 loc) · 2.16 KB
/
MainScores.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
from flask import Flask, render_template_string
app = Flask(__name__)
def read_score_from_file():
try:
with open('score.txt', 'r') as file:
return file.read().strip()
except Exception as e:
return f"ERROR: {str(e)}"
@app.route('/')
def score_server():
score = read_score_from_file()
if score.startswith("ERROR"):
html = f'''
<html>
<head>
<title>World of Games</title>
<style>
body {{
text-align: center;
background-color: #f0f0f0;
font-family: 'Poppins', sans-serif;
}}
.title {{
font-size: 48px;
font-weight: bold;
margin-top: 20px;
}}
h1 {{
font-family: 'Poppins', sans-serif;
font-size: 24px;
color: green;
}}
</style>
</head>
<body>
<h1>{score}</h1>
</body>
</html>
'''
else:
html = f'''
<html>
<head>
<title>World of Games</title>
<style>
body {{
text-align: center;
background-color: #f0f0f0;
font-family: 'Poppins', sans-serif;
}}
.title {{
font-size: 64px;
font-weight: bold;
margin-top: 20px;
}}
h1 {{
font-family: 'Poppins', sans-serif;
font-size: 34px;
color: green;
}}
</style>
</head>
<body>
<h1 class="title">World of Games</h1>
<h1>The global score is {score} pt</h1>
</body>
</html>
'''
return render_template_string(html)
if __name__ == '__main__':
app.run()