Build base web page

This commit is contained in:
2025-01-22 20:56:35 +01:00
parent f31e0ebbcc
commit 3b208c0103
5 changed files with 106 additions and 2 deletions

View File

@ -5,6 +5,7 @@ use crate::user::{User, UserID};
use crate::utils;
use actix_session::Session;
use actix_web::{web, HttpResponse};
use askama::Template;
use light_openid::primitives::OpenIDConfig;
/// Static assets
@ -26,6 +27,10 @@ pub async fn static_file(path: web::Path<String>) -> HttpResult {
}
}
#[derive(askama::Template)]
#[template(path = "index.html")]
struct HomeTemplate {}
/// Main route
pub async fn home(session: Session) -> HttpResult {
// Get user information, requesting authentication if information is missing
@ -46,7 +51,9 @@ pub async fn home(session: Session) -> HttpResult {
.finish());
};
Ok(HttpResponse::Ok().body("You are authenticated!"))
Ok(HttpResponse::Ok()
.insert_header(("content-type", "text/html"))
.body(HomeTemplate {}.render().unwrap()))
}
#[derive(serde::Deserialize)]