diff options
| author | Fuwn <[email protected]> | 2021-05-18 11:47:07 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-18 11:47:07 -0700 |
| commit | 7cb0fcc5bcd29195ad2b5e62ae1ed30d7b4050d0 (patch) | |
| tree | 30834a2e2ae430fd36172487e840dfae9470ddc7 /src | |
| download | records-7cb0fcc5bcd29195ad2b5e62ae1ed30d7b4050d0.tar.xz records-7cb0fcc5bcd29195ad2b5e62ae1ed30d7b4050d0.zip | |
feat(records): :star:
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..07bbff4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,40 @@ +// Copyleft (ɔ) 2021-2021 Fuwn +// SPDX-License-Identifier: GPL-3.0-only + +// #[macro_use] +// extern crate actix_web; +// #[macro_use] +// extern crate log; + +use std::env; + +const INDEX: &str = r#"The Fuwn Records +================ + +Last updated: 2021. 05. 18. +"#; + +#[actix_web::main] +async fn main() -> std::io::Result<()> { + // Environment + dotenv::dotenv().ok(); + std::env::set_var("RUST_LOG", "actix_web=info"); + + // Logging + pretty_env_logger::init(); + + // Web-server + actix_web::HttpServer::new(|| { + actix_web::App::new() + .wrap(actix_cors::Cors::default().allow_any_origin()) + .wrap(actix_web::middleware::Logger::default()) + .service(actix_web::web::resource("/").to(|| async { INDEX })) + .service(actix_files::Files::new("/records", "./records/_/").show_files_listing()) + }) + .bind(format!( + "0.0.0.0:{}", + env::var("PORT").unwrap_or_else(|_| "80".to_string()) + ))? + .run() + .await +} |