use app::*; use axum::Router; use fileserv::file_and_error_handler; use leptos::*; use leptos_axum::{build_static_routes, generate_route_list_with_exclusions_and_ssg, LeptosRoutes}; pub mod fileserv; #[tokio::main] async fn main() { simple_logger::init_with_level(log::Level::Debug).expect("couldn't initialize logging"); // Setting get_configuration(None) means we'll be using cargo-leptos's env values // For deployment these variables are: // // Alternately a file can be specified such as Some("Cargo.toml") // The file would need to be included with the executable when moved to deployment let conf = get_configuration(None).await.unwrap(); let leptos_options = conf.leptos_options; let addr = leptos_options.site_addr; let (routes, data) = generate_route_list_with_exclusions_and_ssg(App, None); build_static_routes(&leptos_options, App, &routes, data).await; // build our application with a route let app = Router::new() .leptos_routes(&leptos_options, routes, App) .fallback(file_and_error_handler) .with_state(leptos_options); // run our app with hyper // `axum::Server` is a re-export of `hyper::Server` let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); log::info!("listening on http://{}", &addr); axum::serve(listener, app.into_make_service()) .await .unwrap(); }