[ { "type": "folder", "name": "src", "children": [ { "type": "folder", "name": "pages", "children": [ { "type": "file", "name": "index.rs", "content": "use actix_web::{HttpResponse, Responder, web};\nuse tera::{Context, Tera};\n\npub async fn get(tera: web::Data) -> Result {\n let context = Context::new();\n let rendered = tera.render(\"index.html\", &context).map_err(|e| {\n eprintln!(\"Failed to render index.html: {}\", e);\n actix_web::error::ErrorInternalServerError(\"Failed to render index.html\")\n })?;\n\n Ok(HttpResponse::Ok().body(rendered))\n}" }, { "type": "file", "name": "mod.rs", "content": "pub mod index;" } ] }, { "type": "file", "name": "main.rs", "content": "use actix_web::{web, App, HttpServer};\n\nmod pages;\n\n#[ruxt::main]\nasync fn main() -> std::io::Result<()> {\n let tera = tera::Tera::new(\"templates/**/*\").expect(\"Failed to compile templates\");\n HttpServer::new(move || App::new().app_data(web::Data::new(tera.clone())))\n .bind((\"0.0.0.0\", 8080))?\n .run()\n .await\n}" } ] }, { "type": "folder", "name": "templates", "children": [ { "type": "file", "name": "index.html", "content": "\n\n\n\n \n \n \n \n Ruxt App\n\n\n \n

This is a Ruxt App

\n

Welcome to your new Ruxt app! Visit ruxt.rs to learn more.

\n\n\n" } ] }, { "type": "file", "name": "Cargo.toml", "content": "[package]\nname = \"{name}\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\nruxt = \"0.1.0\"\nactix-web = \"4.5.1\"\ntera = \"1.19.1\"\n" } ]