Compare commits
3 commits
7275b918f1
...
6601686581
Author | SHA1 | Date | |
---|---|---|---|
6601686581 | |||
f25c8e97b3 | |||
e89430b400 |
6 changed files with 55 additions and 2 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
target
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal 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
11
.idea/ipimg.iml
Normal 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
8
.idea/modules.xml
Normal 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
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
23
src/main.rs
23
src/main.rs
|
@ -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 ab_glyph::FontRef;
|
||||
|
@ -8,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::<SocketAddr>(),
|
||||
|
|
Loading…
Reference in a new issue