add some comments and check if tmp/ exists and create it if not
This commit is contained in:
parent
cf24968725
commit
e86078e889
2 changed files with 11 additions and 0 deletions
1
counter.numb
Normal file
1
counter.numb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0
|
10
src/main.rs
10
src/main.rs
|
@ -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)
|
// 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
|
// 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::{
|
use actix_web::{
|
||||||
get,
|
get,
|
||||||
App,
|
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 MONTAGE_ARGS: &str = "-tile 6x1 -geometry +0+0 -background none -scale 50";
|
||||||
const ASSET_DIR: &str = "asset/";
|
const ASSET_DIR: &str = "asset/";
|
||||||
const TMP_OUTPUT: &str = "tmp/counter.png";
|
const TMP_OUTPUT: &str = "tmp/counter.png";
|
||||||
|
const TMP_DIR: &str = "tmp";
|
||||||
|
|
||||||
|
|
||||||
const BIND_IP: &str = "127.0.0.1";
|
const BIND_IP: &str = "127.0.0.1";
|
||||||
|
@ -104,6 +111,9 @@ async fn main() -> std::io::Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
read_counter();
|
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}");
|
log::info!("starting HTTP server at http://{BIND_IP}:{BIND_PORT}");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue