Skip to content

Commit

Permalink
feat: classic routes and htmx routes now have different files and org…
Browse files Browse the repository at this point in the history
…anization
  • Loading branch information
tm26a21p committed May 31, 2024
1 parent e1bfa82 commit 9f932a0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use axum::{extract::Extension, routing::get, Router};
mod htmx_routes;
mod htmx_templates;
mod project;
mod routes;
mod state;
mod templates;
mod utils;

use routes::*;
use htmx_routes::*;
use state::Common;
extern crate dotenv;

use dotenv::dotenv;

#[tokio::main]
async fn main()
{
Expand All @@ -18,18 +22,23 @@ async fn main()
dotenv().ok();

let app = Router::new()
// classic routes
.route("/", get(index))
.route("/home", get(index))
.route("/metrics", get(metrics))
.route("/projects", get(projects))
.route("/metrics", get(metrics_page))
.route("/projects", get(projects_page))
// .route("/projects/{id}", get(project))
// htmx routes
.route("/api/projects", get(projects))
.route("/api/projects-liked", get(projects_liked))
.nest("/public", using_serve_dir())
.layer(Extension(state.clone()));

let listener = tokio::net::TcpListener::bind("0.0.0.0:4444")
.await
.expect("Failed to bind port 4444");
println!("Listening on: http://{}", "localhost:4444");
println!("Listening on: http://localhost:{}", 4444);
axum::serve(listener, app.into_make_service())
.await
.expect("Server failed")
}
}

0 comments on commit 9f932a0

Please sign in to comment.