Skip to content

Commit fb0d1b3

Browse files
add 404 page
1 parent e2215dd commit fb0d1b3

File tree

5 files changed

+91
-64
lines changed

5 files changed

+91
-64
lines changed

assets/404.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/png" href="/icon.png" />
6+
<link rel="stylesheet" href="/index.css" />
7+
<meta name="viewport" content="width=device-width" />
8+
<meta
9+
property="og:title"
10+
content="mcping.me minecraft server testing API"
11+
/>
12+
<meta property="og:type" content="website" />
13+
<meta property="og:image" content="https://mcping.me/icon.png" />
14+
<meta property="og:url" content="https://mcping.me/" />
15+
<meta property="og:site_name" content="mcping.me" />
16+
<meta property="og:description" content="Page Not Found" />
17+
<meta name="description" content="Page Not Found" />
18+
<title>404 Page Not Found - mcping</title>
19+
</head>
20+
21+
<body>
22+
<h1>404 Page Not Found</h1>
23+
</body>
24+
</html>

assets/api/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
name="description"
2626
content="A simple REST API for pinging Minecraft Java Edition and Bedrock edition servers. Also included: A system to test if some minecraft services are working. Free for all to use."
2727
/>
28-
<title>Minecraft Server Tester</title>
28+
<title>Minecraft Server Testing API - mcping</title>
2929
</head>
3030

3131
<body id="apiBody">

assets/index.css

+60-60
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,122 @@
11
@font-face {
2-
font-family: "Monaspace Neon";
3-
src: url("/MonaspaceNeon-Regular.woff");
4-
font-display: swap;
2+
font-family: "Monaspace Neon";
3+
src: url("/MonaspaceNeon-Regular.woff");
4+
font-display: swap;
55
}
66

77
body {
8-
text-align: center;
9-
background: hsl(200, 4%, 10%);
10-
font-family: "Monaspace Neon", "Courier New", "Courier", monospace;
11-
color: #ffffff;
12-
min-height: 99vh;
13-
display: grid;
14-
grid-template-rows: auto 1fr auto;
15-
overflow-x: hidden;
16-
margin: 0px;
17-
padding: 0px;
8+
text-align: center;
9+
background: hsl(200, 4%, 10%);
10+
font-family: "Monaspace Neon", "Courier New", "Courier", monospace;
11+
color: #ffffff;
12+
min-height: 99vh;
13+
display: grid;
14+
grid-template-rows: auto 1fr auto;
15+
overflow-x: hidden;
16+
margin: 0px;
17+
padding: 0px;
1818
}
1919

2020
body#apiBody {
21-
margin-left: 20%;
22-
margin-right: 20%;
21+
margin-left: 20%;
22+
margin-right: 20%;
2323
}
2424

2525
input {
26-
background: hsl(192, 2%, 40%);
27-
border: #1b8b77;
28-
color: #ffffff;
29-
padding: 20px;
30-
border-radius: 3px;
26+
background: hsl(192, 2%, 40%);
27+
border: #1b8b77;
28+
color: #ffffff;
29+
padding: 20px;
30+
border-radius: 3px;
3131
}
3232

3333
input::placeholder {
34-
color: hsl(192, 2%, 70%);
34+
color: hsl(192, 2%, 70%);
3535
}
3636

3737
a {
38-
color: #43baf4;
38+
color: #43baf4;
3939
}
4040

4141
img {
42-
image-rendering: pixelated;
42+
image-rendering: pixelated;
4343
}
4444

4545
button {
46-
border: none;
47-
border-radius: 5px;
48-
padding: 15px;
49-
color: white;
50-
cursor: pointer;
51-
display: inline-block;
52-
background-color: #43baf4;
53-
text-align: center;
54-
text-decoration: none;
46+
border: none;
47+
border-radius: 5px;
48+
padding: 15px;
49+
color: white;
50+
cursor: pointer;
51+
display: inline-block;
52+
background-color: #43baf4;
53+
text-align: center;
54+
text-decoration: none;
5555
}
5656

5757
footer {
58-
min-height: 50px;
59-
margin-top: 10px;
60-
width: 100%;
58+
min-height: 50px;
59+
margin-top: 10px;
60+
width: 100%;
6161
}
6262

6363
pre > code {
64-
text-align: left;
65-
display: inline-block;
64+
text-align: left;
65+
display: inline-block;
6666
}
6767

6868
.java {
69-
background-color: chartreuse;
70-
color: black;
69+
background-color: chartreuse;
70+
color: black;
7171
}
7272

7373
.bedrock {
74-
background-color: black;
74+
background-color: black;
7575
}
7676

7777
.response {
78-
font-size: 20pt;
78+
font-size: 20pt;
7979
}
8080

8181
.ip {
82-
cursor: pointer;
82+
cursor: pointer;
8383
}
8484

8585
.root-api-status {
86-
display: flex;
87-
justify-content: center;
88-
align-items: center;
89-
width: 100%;
86+
display: flex;
87+
justify-content: center;
88+
align-items: center;
89+
width: 100%;
9090
}
9191

9292
@media (max-width: 110ch) {
93-
.root-api-status {
94-
flex-direction: column;
95-
}
93+
.root-api-status {
94+
flex-direction: column;
95+
}
9696
}
9797

9898
.api-status-container {
99-
margin: 2px 1ch;
100-
padding: 2px 4px;
101-
border-color: white;
102-
border-style: solid;
103-
border-width: 1px;
104-
border-radius: 4px;
105-
width: fit-content;
99+
margin: 2px 1ch;
100+
padding: 2px 4px;
101+
border-color: white;
102+
border-style: solid;
103+
border-width: 1px;
104+
border-radius: 4px;
105+
width: fit-content;
106106
}
107107

108108
.green {
109-
color: #00ff00;
109+
color: #00ff00;
110110
}
111111

112112
.yellow {
113-
color: #ffff00;
113+
color: #ffff00;
114114
}
115115

116116
.red {
117-
color: #ff0000;
117+
color: #ff0000;
118118
}
119119

120120
.blue {
121-
color: #44aaff;
121+
color: #44aaff;
122122
}

assets/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
name="description"
2323
content="mcping.me is a powerful, ad-free Minecraft server tester. Ping Java and Bedrock servers to check if they're working. Check if Mojang or XBox services are having issues. All for free, without ads."
2424
/>
25-
<title>Minecraft Server Tester</title>
25+
<title>Minecraft Server Tester - mcping</title>
2626
</head>
2727

2828
<body>

src/main.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use parking_lot::RwLock;
1919
use reqwest::{header::HeaderMap, redirect::Policy, Client};
2020
use serde::Serialize;
2121
use tokio::{net::TcpListener, select};
22-
use tower_http::services::ServeDir;
22+
use tower_http::services::{ServeDir, ServeFile};
2323
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
2424

2525
use crate::{
@@ -53,12 +53,15 @@ async fn main() {
5353
let current_mcstatus: Arc<RwLock<ServicesResponse>> =
5454
Arc::new(RwLock::new(get_mcstatus(http_client.clone()).await));
5555
tokio::spawn(refresh_mcstatus(http_client, Arc::clone(&current_mcstatus)));
56+
57+
let serve_404 = ServeFile::new(asset_dir.trim_end_matches('/').to_string() + "/404.html");
5658
let serve_dir = ServeDir::new(&asset_dir)
5759
.append_index_html_on_directories(true)
5860
.precompressed_gzip()
5961
.precompressed_br()
6062
.precompressed_deflate()
61-
.precompressed_zstd();
63+
.precompressed_zstd()
64+
.fallback(serve_404);
6265
let app = axum::Router::new()
6366
.route("/api/:address", get(handle_java_ping))
6467
.route("/api/java/:address", get(handle_java_ping))

0 commit comments

Comments
 (0)