add route /game in backend

This commit is contained in:
M1n-0
2026-03-31 14:31:40 +02:00
parent fa1ffc214c
commit 903a1de933
2 changed files with 15 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ use tower_http::services::ServeDir;
async fn main() {
let app = Router::new()
.route("/", get(handler))
.route("/game", get(game))
.nest_service("/web/assets", ServeDir::new("../web/assets"));
let addr = SocketAddr::from(([0, 0, 0, 0], 3500));
@@ -26,6 +27,13 @@ async fn handler() -> Html<String> {
Html(html_content)
}
async fn game() -> Html<String> {
let html_content = read_html_from_file("../web/templates/view/game.html")
.await
.unwrap_or_else(|_| "<h1>Error loading HTML file</h1>".to_string());
Html(html_content)
}
async fn read_html_from_file<P: AsRef<Path>>(path: P) -> io::Result<String> {
let mut file = File::open(path).await?;
let mut contents = String::new();

View File

@@ -14,11 +14,13 @@
<div class="hero-content">
<h1>MirrorGame</h1>
<img src="https://upload.wikimedia.org/wikipedia/commons/f/f3/Meow_cat_-_Mdebona.jpg" alt="MirrorGame">
<button class="hero-play-button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play" viewBox="0 0 16 16">
<path d="M10.804 8 5 4.633v6.734zm.792-.696a.802.802 0 0 1 0 1.392l-6.363 3.692C4.713 12.69 4 12.345 4 11.692V4.308c0-.653.713-.998 1.233-.696z"/>
</svg>
</button>
<a href="/game">
<button class="hero-play-button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play" viewBox="0 0 16 16">
<path d="M10.804 8 5 4.633v6.734zm.792-.696a.802.802 0 0 1 0 1.392l-6.363 3.692C4.713 12.69 4 12.345 4 11.692V4.308c0-.653.713-.998 1.233-.696z"/>
</svg>
</button>
</a>
</div>
</div>
<aside class="leftadsbanner">