everything ready !
This commit is contained in:
parent
aa5140842e
commit
0cbee2e73e
7 changed files with 44 additions and 1 deletions
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod templates;
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
use agahnim_web_v2::templates::index::home;
|
||||
use axum::{Router, routing::get};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let app = Router::new()
|
||||
.route("/", get(|| async { "Hello World" }))
|
||||
.route("/", get(home))
|
||||
.nest_service("/static", ServeDir::new("static"));
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:7122")
|
||||
|
|
|
|||
10
src/templates/index.rs
Normal file
10
src/templates/index.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use askama::Template;
|
||||
use axum::response::{Html, IntoResponse};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate;
|
||||
|
||||
pub async fn home() -> impl IntoResponse {
|
||||
Html(IndexTemplate.render().unwrap())
|
||||
}
|
||||
1
src/templates/mod.rs
Normal file
1
src/templates/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod index;
|
||||
16
templates/base.html
Normal file
16
templates/base.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>{% block title %}Mon Site{% endblock %}</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% include "partials/header.html" %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
8
templates/index.html
Normal file
8
templates/index.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Accueil{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Bonjour</h1>
|
||||
<p>Bienvenue sur mon site.</p>
|
||||
{% endblock %}
|
||||
6
templates/partials/header.html
Normal file
6
templates/partials/header.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<header>
|
||||
<nav>
|
||||
<a href="/">Accueil</a>
|
||||
<a href="/blog">Blog</a>
|
||||
</nav>
|
||||
</header>
|
||||
Loading…
Add table
Add a link
Reference in a new issue