Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

main.rs 885 Bytes
Newer Older
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mod media_folder_utils;
mod service;

use hyper::service::{make_service_fn, service_fn};
use hyper::{Server, Response, Body, Request, StatusCode};
use std::convert::Infallible;
use std::net::SocketAddr;
use std::ops::Range;
use std::env;
use std::fs;
use futures::StreamExt;
use std::collections::HashMap;
use std::path::Path;
use crate::media_folder_utils::{visit_dirs, MediaFileCache};
use crate::service::MakeSvc;
16
use tokio::time::Duration;
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
17
18
19
20
21
22

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    let args = env::args();

23
24
25
26
    let server = Server::bind(&addr).serve(MakeSvc{
        base_dir: args.skip(1).take(1).collect::<String>(),
        outdated_after: Duration::new(7200, 0),
    });
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
27
28
29
30
31
32

    if let Err(e) = server.await {
        eprintln!("server error: {}", e);
    }
    Ok(())
}