aboutsummaryrefslogtreecommitdiff
path: root/src/spectate/server.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-04 20:48:43 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-04 20:48:43 +0200
commit4ebe819106d82459def54561cf8dc71ec22ba6e4 (patch)
tree991046e078bf9de21cc392343401ef1d46a8962c /src/spectate/server.rs
parente49a85505701740b195a03892e1fc5cf8d6382a2 (diff)
downloadgpn-tron-rust-4ebe819106d82459def54561cf8dc71ec22ba6e4.tar
gpn-tron-rust-4ebe819106d82459def54561cf8dc71ec22ba6e4.tar.bz2
gpn-tron-rust-4ebe819106d82459def54561cf8dc71ec22ba6e4.tar.zst
save creds
Diffstat (limited to 'src/spectate/server.rs')
-rw-r--r--src/spectate/server.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/spectate/server.rs b/src/spectate/server.rs
index da18a77..11c4d5a 100644
--- a/src/spectate/server.rs
+++ b/src/spectate/server.rs
@@ -47,6 +47,19 @@ pub async fn spectate_server(config: Config, state: Arc<State>) -> Result<()> {
Ok(())
}
+#[cfg(debug_assertions)]
+async fn index() -> Html<String> {
+ use tokio::fs::read_to_string;
+ Html(
+ read_to_string(concat!(
+ env!("CARGO_MANIFEST_DIR"),
+ "/src/spectate/index.html"
+ ))
+ .await
+ .unwrap(),
+ )
+}
+#[cfg(not(debug_assertions))]
async fn index() -> Html<&'static str> {
Html(include_str!("index.html"))
}
@@ -91,13 +104,7 @@ async fn css() -> (HeaderMap, &'static str) {
use headers::HeaderMapExt;
let mut hm = HeaderMap::new();
hm.typed_insert(ContentType::from_str("text/css").unwrap());
- (
- hm,
- include_str!(concat!(
- env!("CARGO_MANIFEST_DIR"),
- "/src/spectate/style.css"
- )),
- )
+ (hm, include_str!("style.css"))
}
async fn broadcaster(sstate: Arc<SpectateState>, state: Arc<State>) {