based/examples/basic.rs
2025-01-21 16:39:47 +01:00

30 lines
691 B
Rust

use based::get_pg;
use based::request::{RequestContext, StringResponse};
use based::ui::components::Shell;
use based::ui::prelude::Nothing;
use maud::html;
use rocket::get;
use rocket::routes;
#[get("/")]
pub async fn index_page(ctx: RequestContext) -> StringResponse {
let content = html!(
h1 { "Hello World!" };
);
Shell::new(Nothing(), Nothing(), Nothing())
.render_page(content, "Hello World", ctx)
.await
}
#[rocket::launch]
async fn launch() -> _ {
// Logging
env_logger::init();
// Database
let pg = get_pg!();
// sqlx::migrate!("./migrations").run(pg).await.unwrap();
rocket::build().mount("/", routes![index_page])
}