Init rocket backend, base layout to be extended by other html
This commit is contained in:
23
src/main.rs
Normal file
23
src/main.rs
Normal 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])
|
||||
}
|
||||
Reference in New Issue
Block a user