use websurfx::server::routes; use actix_files as fs; use actix_web::{web, App, HttpServer}; use handlebars::Handlebars; // The function that launches the main server and handle routing functionality #[actix_web::main] async fn main() -> std::io::Result<()> { let mut handlebars: Handlebars = Handlebars::new(); handlebars .register_templates_directory(".html", "./public/templates") .unwrap(); let handlebars_ref: web::Data = web::Data::new(handlebars); HttpServer::new(move || { App::new() .app_data(handlebars_ref.clone()) // Serve images and static files (css and js files). .service(fs::Files::new("/static", "./public/static").show_files_listing()) .service(fs::Files::new("/images", "./public/images").show_files_listing()) .service(routes::robots_data) // robots.txt .service(routes::index) // index page .service(routes::search) // search page .service(routes::about) // about page .service(routes::settings) // settings page .default_service(web::route().to(routes::not_found)) // error page }) // Start server on 127.0.0.1:8080 .bind(("127.0.0.1", 8080))? .run() .await }