add some comments and check if tmp/ exists and create it if not

This commit is contained in:
jake 2024-03-24 12:22:00 -04:00
parent cf24968725
commit e86078e889
2 changed files with 11 additions and 0 deletions

1
counter.numb Normal file
View file

@ -0,0 +1 @@
0

View file

@ -1,5 +1,11 @@
// hit-counter-rs
// it's a hit counter, but in rust. I am also very new to rust, ごめん
//
// Due to the slowness of imagemagick (and calling system commands and w/e else)
// the image that the user will see on the page will be -1 behind the actual count
//
// todo:
// all files are relative to working directory -> specifiy via cli and/or some config file
use actix_web::{
get,
App,
@ -19,6 +25,7 @@ const MONTAGE_PATH: &str = "/bin/montage";
//const MONTAGE_ARGS: &str = "-tile 6x1 -geometry +0+0 -background none -scale 50";
const ASSET_DIR: &str = "asset/";
const TMP_OUTPUT: &str = "tmp/counter.png";
const TMP_DIR: &str = "tmp";
const BIND_IP: &str = "127.0.0.1";
@ -104,6 +111,9 @@ async fn main() -> std::io::Result<()> {
unsafe {
read_counter();
}
if !std::path::Path::new(TMP_DIR).exists() {
std::fs::create_dir(TMP_DIR)?;
}
log::info!("starting HTTP server at http://{BIND_IP}:{BIND_PORT}");