Compare commits

...

3 commits

Author SHA1 Message Date
6601686581 allow more configuration 2024-06-01 11:44:14 +01:00
f25c8e97b3 main 2024-06-01 11:30:18 +01:00
e89430b400 gitignore 2024-06-01 11:26:36 +01:00
6 changed files with 55 additions and 2 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
target

8
.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

11
.idea/ipimg.iml Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ipimg.iml" filepath="$PROJECT_DIR$/.idea/ipimg.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -1,3 +1,19 @@
/////////////////////////////////////
// //
// TO EDIT NETWORK STUFF EDIT: //
// - const IPADDRESS //
// - const PORT //
// //
// TO EDIT FONT: //
// - Add your font to root dir //
// - edit const FONTFILENAME //
// //
/////////////////////////////////////
const IPADDRESS: &str = "0.0.0.0";
const PORT: &str = "8080";
const FONTFILENAME: &str = "Roboto-Regular.ttf"
use std::{io::Cursor, net::SocketAddr}; use std::{io::Cursor, net::SocketAddr};
use ab_glyph::FontRef; use ab_glyph::FontRef;
@ -8,12 +24,15 @@ use imageproc::drawing::{self, text_size};
#[tokio::main] #[tokio::main]
async fn 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 font = FontRef::try_from_slice(fontfile).unwrap();
let app = Router::new().route("/ip.png", get(ip_png)).with_state(font); 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( axum::serve(
list, list,
app.into_make_service_with_connect_info::<SocketAddr>(), app.into_make_service_with_connect_info::<SocketAddr>(),