From 6601686581c8bc1892206d581c593f51a2da5498 Mon Sep 17 00:00:00 2001 From: endernon Date: Sat, 1 Jun 2024 11:44:14 +0100 Subject: [PATCH] allow more configuration --- src/main.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1480b3c..e746b64 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,18 @@ -/////////////////////////////////////////// -// // -// TO EDIT NETWORK STUFF EDIT BELOW: // -// - const IPADDRESS // -// - const PORT // -// // -/////////////////////////////////////////// +///////////////////////////////////// +// // +// TO EDIT NETWORK STUFF EDIT: // +// - const IPADDRESS // +// - const PORT // +// // +// TO EDIT FONT: // +// - Add your font to root dir // +// - edit const FONTFILENAME // +// // +///////////////////////////////////// -const IPADDRESS: &str = "69"; +const IPADDRESS: &str = "0.0.0.0"; const PORT: &str = "8080"; +const FONTFILENAME: &str = "Roboto-Regular.ttf" use std::{io::Cursor, net::SocketAddr}; @@ -19,12 +24,15 @@ use imageproc::drawing::{self, text_size}; #[tokio::main] async fn main() { - let fontfile = include_bytes!("../Roboto-Regular.ttf"); + let networkaddress = format!("{IPADDRESS}:{PORT}"); + let fontname2 = format!("../{FONTFILENAME}") + + let fontfile = include_bytes!(fontname2); let font = FontRef::try_from_slice(fontfile).unwrap(); let app = Router::new().route("/ip.png", get(ip_png)).with_state(font); - let list = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap(); + let list = tokio::net::TcpListener::bind(networkaddress).await.unwrap(); axum::serve( list, app.into_make_service_with_connect_info::(),