chore: initialized repository

This commit is contained in:
Lukas Wölfer
2026-04-08 22:45:47 +02:00
commit 024d64b284
11 changed files with 2483 additions and 0 deletions

27
src/main.rs Normal file
View File

@@ -0,0 +1,27 @@
use axum::{
routing::get,
Router,
};
use tower_http::services::ServeDir;
use sqlx::SqlitePool;
#[tokio::main]
async fn main() {
// Set up database
let database_url = "sqlite:weight_tracker.db";
let pool = SqlitePool::connect(database_url).await.expect("Failed to connect to database");
// build our application with a route
let app = Router::new()
.route("/", get(weight_tracker::handlers::index))
.route("/input", get(weight_tracker::handlers::input_get).post(weight_tracker::handlers::input_post))
.with_state(pool)
.nest_service("/static", ServeDir::new("static"));
// run it
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
println!("listening on {}", listener.local_addr().unwrap());
axum::serve(listener, app).await.unwrap();
}