added version
This commit is contained in:
parent
5647dbd783
commit
f86e4127e8
@ -24,6 +24,7 @@ import lombok.extern.log4j.Log4j2;
|
|||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class BasketballServer {
|
public class BasketballServer {
|
||||||
|
private static final String VERSION = "1.0.1";
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
log.info("Starting Basketball Server...");
|
log.info("Starting Basketball Server...");
|
||||||
@ -135,29 +136,21 @@ public class BasketballServer {
|
|||||||
static class WebHandler implements HttpHandler {
|
static class WebHandler implements HttpHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handle(HttpExchange exchange) throws IOException {
|
public void handle(HttpExchange exchange) throws IOException {
|
||||||
log.debug("Handling Web request: {}", exchange.getRequestURI());
|
try {
|
||||||
try {
|
String content = readResource("/index.html");
|
||||||
String path = exchange.getRequestURI().getPath();
|
// Replace version placeholder with actual version
|
||||||
if ("/".equals(path) || path.isEmpty() || path.equals("/index.html")) {
|
content = content.replace("${version}", VERSION);
|
||||||
String html = readResource("/index.html");
|
|
||||||
if (html == null) {
|
exchange.getResponseHeaders().set("Content-Type", "text/html; charset=utf-8");
|
||||||
sendError(exchange, 404, "index.html not found in resources");
|
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
|
||||||
return;
|
exchange.sendResponseHeaders(200, bytes.length);
|
||||||
}
|
try (OutputStream os = exchange.getResponseBody()) {
|
||||||
exchange.getResponseHeaders().set("Content-Type", "text/html; charset=utf-8");
|
os.write(bytes);
|
||||||
byte[] bytes = html.getBytes(StandardCharsets.UTF_8);
|
}
|
||||||
exchange.sendResponseHeaders(200, bytes.length);
|
} catch (Exception e) {
|
||||||
try (OutputStream os = exchange.getResponseBody()) {
|
log.error("Error handling web request: ", e);
|
||||||
os.write(bytes);
|
sendError(exchange, 500, e.getMessage());
|
||||||
os.flush();
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sendError(exchange, 404, "Not found");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error handling web request: ", e);
|
|
||||||
sendError(exchange, 500, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,14 @@ tr.nymburk {
|
|||||||
tr:nth-child(even) { background-color: #f9f9f9; }
|
tr:nth-child(even) { background-color: #f9f9f9; }
|
||||||
a { color: #2980b9; text-decoration: none; }
|
a { color: #2980b9; text-decoration: none; }
|
||||||
a:hover { text-decoration: underline; }
|
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) {
|
@media (max-width: 600px) {
|
||||||
h1 { font-size: 1.3rem; margin-bottom: 12px; }
|
h1 { font-size: 1.3rem; margin-bottom: 12px; }
|
||||||
.controls { flex-direction: column; align-items: stretch; }
|
.controls { flex-direction: column; align-items: stretch; }
|
||||||
@ -142,6 +150,10 @@ a:hover { text-decoration: underline; }
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
v${version} © 2025 kAmMa. All rights reserved.
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let allMatchesGlobal = [];
|
let allMatchesGlobal = [];
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user