Init rocket backend, base layout to be extended by other html

This commit is contained in:
2024-08-08 11:59:59 +02:00
parent 6750c65bd0
commit 07ae4c4118
14 changed files with 1766 additions and 123 deletions

23
src/main.rs Normal file
View File

@@ -0,0 +1,23 @@
#[macro_use] extern crate rocket;
#[macro_use] extern crate rocket_db_pools;
use rocket::fs::{FileServer, relative};
use rocket_dyn_templates::{Template, context};
#[get("/table/<tname>")]
fn table(tname: &str) -> Template {
Template::render("table", context!{tname: tname, columns: ["name", "djhfae", "fsjhr"], rows: [["1", "first", "hasdjf", "753rgf"], ["2", "second", "7438ued", "🚀"], ["3", "third", "", ""]] })
}
#[get("/")]
fn index() -> Template {
Template::render("test", context!{foo: 123,})
}
#[launch]
fn rocket() -> _ {
rocket::build()
.attach(Template::fairing())
.mount("/", FileServer::from(relative!("static")))
.mount("/", routes![index, table])
}