This commit is contained in:
Adam 2024-06-23 04:49:32 -04:00
parent 7fa45dc9b7
commit eeae337ef2
8 changed files with 83 additions and 56 deletions

27
Cargo.lock generated
View file

@ -107,6 +107,28 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "axum-extra"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0be6ea09c9b96cb5076af0de2e383bd2bc0c18f827cf1967bdd353e0b910d733"
dependencies = [
"axum",
"axum-core",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"mime",
"pin-project-lite",
"serde",
"tower",
"tower-layer",
"tower-service",
"tracing",
]
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.73" version = "0.3.73"
@ -161,6 +183,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
"axum-extra",
"futures", "futures",
"rand", "rand",
"serde", "serde",
@ -453,9 +476,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "libc" name = "libc"

View file

@ -14,3 +14,4 @@ tower = { version = "0.4", features = ["util"] }
tracing = "0.1" tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
anyhow = "1.0.82" anyhow = "1.0.82"
axum-extra = "0.9.3"

View file

@ -3,6 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Cards For Humanity</title> <title>Cards For Humanity</title>
<link type="text/css" rel="stylesheet" href="css">
</head> </head>
<body> <body>
<h1>Cards For Humanity</h1> <h1>Cards For Humanity</h1>

36
public/main.css Normal file
View file

@ -0,0 +1,36 @@
html,
body,
input,
textarea,
button {
font-family: monospace;
background-color: #111;
color: #ddd;
margin: 0;
padding: 0;
}
div {
margin-top: 1rem;
}
span {
padding-left: 1rem;
}
p {
margin: 0;
padding: 0;
}
input {
display: block;
width: 10rem;
box-sizing: border-box;
}
iframe {
width: 49%;
height: 49vh;
border-style: none;
}
.container {
width: 100vw;
height: 100vh;
display: flex;
}

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Cards For Humanity Reference Client</title> <title>Cards For Humanity Reference Client</title>
<style></style> <link type="text/css" rel="stylesheet" href="css">
</head> </head>
<body> <body>
<h1>Cards For Humanity Reference Client</h1> <h1>Cards For Humanity Reference Client</h1>

View file

@ -1,25 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Cards For Humanity Test Clients</title> <title>Cards For Humanity Test Clients</title>
<style> <link type="text/css" rel="stylesheet" href="css">
body, html {
margin: 0;
padding: 0;
background-color: #000;
overflow: hidden;
}
iframe {
width: 49%;
height: 49vh;
border-style: none;
}
.container {
width: 100vw;
height: 100vh;
display: flex;
}
</style>
</head> </head>
<body> <body>
<div id="container"> <div id="container">

View file

@ -3,30 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Cards For Humanity Test Client</title> <title>Cards For Humanity Test Client</title>
<style> <link type="text/css" rel="stylesheet" href="css">
html, body, input, textarea, button {
font-family: monospace;
background-color: #111;
color: #DDD;
margin: 0;
parring: 0;
}
div {
margin-top: 1rem;
}
span {
padding-left: 1rem;
}
p {
margin: 0;
padding: 0;
}
input {
display: block;
width: 10rem;
box-sizing: border-box;
}
</style>
</head> </head>
<body> <body>
<h1>Cards For Humanity Test Client</h1> <h1>Cards For Humanity Test Client</h1>

View file

@ -1,4 +1,5 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use axum_extra::response::Css;
use axum::{response::Html, routing::get, Router}; use axum::{response::Html, routing::get, Router};
use std::{ use std::{
// collections::HashSet, // collections::HashSet,
@ -101,6 +102,9 @@ async fn spawn_clients() -> Html<&'static str> {
async fn reference_client() -> Html<&'static str> { async fn reference_client() -> Html<&'static str> {
Html(std::include_str!("../public/reference_client.html")) Html(std::include_str!("../public/reference_client.html"))
} }
async fn css() -> Css<&'static str> {
Css(std::include_str!("../public/main.css"))
}
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
@ -133,6 +137,7 @@ async fn main() -> Result<()> {
.route("/test_client", get(test_client)) .route("/test_client", get(test_client))
.route("/reference_client", get(reference_client)) .route("/reference_client", get(reference_client))
.route("/websocket", get(websocket_handler)) .route("/websocket", get(websocket_handler))
.route("/css", get(css))
.with_state(app_state); .with_state(app_state);
// send it // send it