diff --git a/src/main/java/cz/kamma/czb/BasketballServer.java b/src/main/java/cz/kamma/czb/BasketballServer.java index ab84ac0..6bad0bc 100644 --- a/src/main/java/cz/kamma/czb/BasketballServer.java +++ b/src/main/java/cz/kamma/czb/BasketballServer.java @@ -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,29 +136,21 @@ 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; - } - exchange.getResponseHeaders().set("Content-Type", "text/html; charset=utf-8"); - byte[] bytes = html.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); - sendError(exchange, 500, e.getMessage()); - } + try { + 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 = content.getBytes(StandardCharsets.UTF_8); + exchange.sendResponseHeaders(200, bytes.length); + try (OutputStream os = exchange.getResponseBody()) { + os.write(bytes); + } + } catch (Exception e) { + log.error("Error handling web request: ", e); + sendError(exchange, 500, e.getMessage()); + } } } diff --git a/src/main/resources/index.html b/src/main/resources/index.html index b19c1c3..84117fc 100644 --- a/src/main/resources/index.html +++ b/src/main/resources/index.html @@ -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; } +
+