From 920496c85bdf0d017eaf837cbacd136d7d828669 Mon Sep 17 00:00:00 2001 From: fx Date: Sun, 8 Oct 2023 23:28:10 +0200 Subject: base web server --- src/main.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..60f2214 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,43 @@ +use axum::{Router, routing::post}; +use time::util::local_offset; +use tracing::{info, level_filters::LevelFilter}; +use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*}; +use crate::routes::start::start; + +mod auth; +mod routes; + +#[tokio::main] +async fn main() { + + unsafe { local_offset::set_soundness(local_offset::Soundness::Unsound); } + let time_format = + time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); + let loc = LocalTime::new(time_format); + + tracing_subscriber::registry() + .with(fmt::layer() + .with_timer(loc) + ) + .with( + EnvFilter::builder() + .with_default_directive(LevelFilter::INFO.into()) + .from_env_lossy(), + ) + .init(); + + let version = env!("CARGO_PKG_VERSION"); + + info!("Starting webol v{}", version); + + // build our application with a single route + let app = Router::new() + .route("/start", post(start)); + + // run it with hyper on localhost:3000 + axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) + .serve(app.into_make_service()) + .await + .unwrap(); +} + -- cgit v1.2.3