Compare commits

...

5 Commits

3 changed files with 602 additions and 523 deletions

1109
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -49,7 +49,16 @@ struct ApplicationState {
#[tokio::main]
async fn main() {
let image_path = args_os().nth(1).expect("Usage: image-gallery IMAGE_DIRECTORY");
let args = args_os()
.skip(1)
.collect::<Vec<_>>();
let args = args
.windows(2)
.next()
.expect("Usage: image-gallery IMAGE_DIRECTORY PORT");
let image_path = &args[0];
let port = args[1].to_string_lossy().parse::<u16>().expect("Invalid port specified");
let mut secret_key: SecretKey = [0; 64];
OsRng.fill_bytes(&mut secret_key);
@ -107,7 +116,7 @@ async fn main() {
cpu_task_limit: Arc::new(Semaphore::new(4)),
});
let addr = SocketAddr::from(([0, 0, 0, 0], 9030));
let addr = SocketAddr::from(([127, 0, 0, 1], port));
tracing::info!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
@ -181,7 +190,7 @@ async fn update_config_and_image_list_cache_job(
// flatten ignores io error while traversing the iterator
images.flatten().filter_map(|entry| {
let path = entry.path();
if path.extension() == Some(OsStr::new("jpg")) {
if path.extension().unwrap_or_default().to_ascii_lowercase() == "jpg" {
Some(path)
} else {
None

View File

@ -8,6 +8,7 @@
margin: 0;
}
header {
font-family: sans-serif;
font-size: 1.3rem;
padding: 1rem;
margin-bottom: 1rem;