added version

This commit is contained in:
Radek Davidek 2025-11-02 16:31:01 +01:00
parent 5647dbd783
commit f86e4127e8
2 changed files with 28 additions and 23 deletions

View File

@ -24,6 +24,7 @@ import lombok.extern.log4j.Log4j2;
@Log4j2
public class BasketballServer {
private static final String VERSION = "1.0.1";
public static void main(String[] args) throws Exception {
log.info("Starting Basketball Server...");
@ -135,24 +136,16 @@ public class BasketballServer {
static class WebHandler implements HttpHandler {
@Override
public void handle(HttpExchange exchange) throws IOException {
log.debug("Handling Web request: {}", exchange.getRequestURI());
try {
String path = exchange.getRequestURI().getPath();
if ("/".equals(path) || path.isEmpty() || path.equals("/index.html")) {
String html = readResource("/index.html");
if (html == null) {
sendError(exchange, 404, "index.html not found in resources");
return;
}
String content = readResource("/index.html");
// Replace version placeholder with actual version
content = content.replace("${version}", VERSION);
exchange.getResponseHeaders().set("Content-Type", "text/html; charset=utf-8");
byte[] bytes = html.getBytes(StandardCharsets.UTF_8);
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
exchange.sendResponseHeaders(200, bytes.length);
try (OutputStream os = exchange.getResponseBody()) {
os.write(bytes);
os.flush();
}
} else {
sendError(exchange, 404, "Not found");
}
} catch (Exception e) {
log.error("Error handling web request: ", e);

View File

@ -95,6 +95,14 @@ tr.nymburk {
tr:nth-child(even) { background-color: #f9f9f9; }
a { color: #2980b9; text-decoration: none; }
a:hover { text-decoration: underline; }
.footer {
text-align: center;
padding: 20px 0;
margin-top: 20px;
color: #666;
font-size: 12px;
border-top: 1px solid #eee;
}
@media (max-width: 600px) {
h1 { font-size: 1.3rem; margin-bottom: 12px; }
.controls { flex-direction: column; align-items: stretch; }
@ -142,6 +150,10 @@ a:hover { text-decoration: underline; }
</table>
</div>
<div class="footer">
v${version} &copy; 2025 kAmMa. All rights reserved.
</div>
<script>
let allMatchesGlobal = [];