bettermint commited on
Commit
a7c7b59
·
verified ·
1 Parent(s): 7e23a6d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +73 -6
main.py CHANGED
@@ -1,5 +1,6 @@
1
  from fastapi import FastAPI, Request, WebSocket
2
  from fastapi.templating import Jinja2Templates
 
3
  import subprocess
4
  import asyncio
5
  import os
@@ -130,9 +131,75 @@ async def websocket_endpoint(websocket: WebSocket, elo: str):
130
 
131
  @app.get("/")
132
  async def root(request: Request):
133
- return templates.TemplateResponse("index.html", {
134
- "request": request,
135
- "total_users": user_playing['total'],
136
- "stockfish_users": user_playing['stockfish'],
137
- "maia_users": user_playing['maia']
138
- })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI, Request, WebSocket
2
  from fastapi.templating import Jinja2Templates
3
+ from fastapi.responses import HTMLResponse
4
  import subprocess
5
  import asyncio
6
  import os
 
131
 
132
  @app.get("/")
133
  async def root(request: Request):
134
+ return HTMLResponse("""<!DOCTYPE html>
135
+ <html lang="en">
136
+ <head>
137
+ <meta charset="UTF-8">
138
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
139
+ <title>Users playing now</title>
140
+ <style>
141
+ body {
142
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
143
+ background-color: #1f1f1f;
144
+ color: #f0f0f0;
145
+ margin: 0;
146
+ padding: 0;
147
+ display: flex;
148
+ justify-content: center;
149
+ align-items: center;
150
+ height: 100vh;
151
+ text-align: center;
152
+ }
153
+ .container {
154
+ background-color: #2d2d2d;
155
+ padding: 20px;
156
+ border-radius: 10px;
157
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
158
+ max-width: 400px;
159
+ width: 100%;
160
+ margin: 20px;
161
+ }
162
+ h1 {
163
+ color: #f0f0f0;
164
+ font-size: 2.5rem;
165
+ margin-bottom: 20px;
166
+ }
167
+ .stat {
168
+ margin-bottom: 10px;
169
+ display: flex;
170
+ justify-content: space-between;
171
+ align-items: center;
172
+ padding: 10px;
173
+ border-bottom: 1px solid #444;
174
+ }
175
+ .stat:last-child {
176
+ border-bottom: none;
177
+ }
178
+ .stat label {
179
+ font-weight: bold;
180
+ font-size: 1.2rem;
181
+ }
182
+ .stat span {
183
+ font-size: 1.2rem;
184
+ }
185
+ </style>
186
+ </head>
187
+ <body>
188
+ <div class="container">
189
+ <h1>Users playing now</h1>
190
+ <div class="stat">
191
+ <label>Total Users:</label>
192
+ <span id="total-users">""" + user_playing["total"] + """</span>
193
+ </div>
194
+ <div class="stat">
195
+ <label>Stockfish Users:</label>
196
+ <span id="stockfish-users">""" + user_playing["stockfish"] """</span>
197
+ </div>
198
+ <div class="stat">
199
+ <label>Maia Users:</label>
200
+ <span id="maia-users">""" + user_playing["maia"] + """</span>
201
+ </div>
202
+ </div>
203
+ </body>
204
+ </html>
205
+ """)