Initial commit

This commit is contained in:
2024-08-21 14:15:51 +02:00
commit fa4a5458c2
6 changed files with 2032 additions and 0 deletions

33
src/main.rs Normal file
View File

@ -0,0 +1,33 @@
use actix_web::middleware::Logger;
use actix_web::{web, App, HttpResponse, HttpServer};
use log::LevelFilter;
use rand::Rng;
async fn home() -> HttpResponse {
log::info!("Successfully found the port!");
HttpResponse::Ok()
.content_type("text/html")
.body(include_str!("../assets/home.html"))
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::Builder::new()
.filter_module("actix_server::server", LevelFilter::Warn)
.filter(None, LevelFilter::Info)
.init();
log::info!("Choosing a random port to start...");
let mut rng = rand::thread_rng();
let port: u16 = 80 + rng.random::<u16>() % 10000;
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.route("/", web::get().to(home))
})
.bind(("127.0.0.1", port))?
.run()
.await
}