quoter/src/main.rs

32 lines
833 B
Rust
Raw Normal View History

2024-08-31 00:32:37 +00:00
mod app_state;
mod auth;
mod handlers;
mod s3_utils;
mod thumbnail;
2024-04-08 07:17:14 +00:00
2024-08-31 00:32:37 +00:00
use actix_web::{middleware::Logger, web, App, HttpServer};
use app_state::AppState;
use handlers::{proxy_handler, upload_handler};
2023-09-27 23:08:48 +00:00
#[actix_web::main]
async fn main() -> std::io::Result<()> {
2024-08-30 19:11:21 +00:00
let app_state = AppState::new().await;
2024-08-30 20:27:01 +00:00
let app_state_clone = app_state.clone();
tokio::spawn(async move {
2024-08-31 00:32:37 +00:00
app_state_clone.update_filelist_from_aws().await;
2024-08-30 20:27:01 +00:00
app_state_clone.refresh_file_list_periodically().await;
});
2023-09-27 23:08:48 +00:00
HttpServer::new(move || {
App::new()
2024-08-30 19:11:21 +00:00
.app_data(web::Data::new(app_state.clone()))
2023-10-11 20:03:12 +00:00
.wrap(Logger::default())
2024-08-31 00:32:37 +00:00
.route("/{path:.*}", web::get().to(proxy_handler))
.route("/", web::post().to(upload_handler))
2023-09-27 23:08:48 +00:00
})
2024-08-30 18:05:51 +00:00
.bind("127.0.0.1:8080")?
2023-09-27 23:08:48 +00:00
.run()
.await
2024-08-30 19:24:47 +00:00
}