i hate israel
This commit is contained in:
@@ -11,6 +11,7 @@ pub async fn start() -> anyhow::Result<()> {
|
||||
let addr = "0.0.0.0:3000";
|
||||
let app = Router::new()
|
||||
.route("/", get(pages::home::get_page))
|
||||
.route("/login", get(pages::login::get_page))
|
||||
.nest_service(
|
||||
"/static",
|
||||
ServiceBuilder::new()
|
||||
|
||||
48
src/web/pages/login.rs
Normal file
48
src/web/pages/login.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use askama::Template;
|
||||
use axum::response::{Html, IntoResponse, Response};
|
||||
|
||||
use axum::{
|
||||
routing::{get, post},
|
||||
http::StatusCode,
|
||||
Json, Router,
|
||||
};
|
||||
|
||||
use crate::web::pages::{BaseTemplate, BaseTemplateCtx};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "login.html")]
|
||||
pub struct HomeTemplate {
|
||||
pub ctx: BaseTemplateCtx,
|
||||
|
||||
}
|
||||
|
||||
impl BaseTemplate for HomeTemplate {
|
||||
fn ctx(&self) -> &BaseTemplateCtx {
|
||||
&self.ctx
|
||||
}
|
||||
fn ctx_mut(&mut self) -> &mut BaseTemplateCtx {
|
||||
&mut self.ctx
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
pub async fn get_page() -> Response {
|
||||
fn inner() -> anyhow::Result<(StatusCode, String)> {
|
||||
let mut template = HomeTemplate {
|
||||
ctx: Default::default()
|
||||
};
|
||||
|
||||
template.set_title("Login");
|
||||
|
||||
Ok((StatusCode::OK, template.render()?))
|
||||
}
|
||||
|
||||
match inner() {
|
||||
Ok((status, s)) => (status, Html(s)).into_response(),
|
||||
Err(e) => {
|
||||
let s = crate::web::pages::error::get_error_page(e.to_string()).await;
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Html(s)).into_response()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
|
||||
|
||||
pub mod home;
|
||||
pub mod login;
|
||||
pub mod error;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user