it brokey
This commit is contained in:
parent
e90350b1f7
commit
d4ae60eed9
17
src/main.rs
17
src/main.rs
|
@ -1,27 +1,14 @@
|
||||||
use actix_web_lab::respond::Html;
|
use actix_web_lab::respond::Html;
|
||||||
use askama::Template;
|
|
||||||
use actix_web::{web, App, HttpServer, Result, Responder};
|
use actix_web::{web, App, HttpServer, Result, Responder};
|
||||||
|
|
||||||
#[derive(Template)]
|
mod public;
|
||||||
#[template(path = "index.html")]
|
|
||||||
struct IndexTemplate<'a> {
|
|
||||||
placeholder: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn index() -> Result<impl Responder> {
|
|
||||||
let html = IndexTemplate {
|
|
||||||
placeholder: "hewwo world"
|
|
||||||
}.render().expect("Failed to render index.html");
|
|
||||||
|
|
||||||
Ok(Html(html))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.route("/", web::get().to(index))
|
.route("/", public::get().to(index))
|
||||||
})
|
})
|
||||||
|
|
||||||
.bind("0.0.0.0:8080")?
|
.bind("0.0.0.0:8080")?
|
||||||
|
|
13
src/public/mod.rs
Normal file
13
src/public/mod.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use actix_web_lab::respond::Html;
|
||||||
|
use actix_web::{Result, Responder};
|
||||||
|
|
||||||
|
mod templates;
|
||||||
|
|
||||||
|
async fn index() -> Result<impl Responder> {
|
||||||
|
let html = templates::IndexTemplate {
|
||||||
|
placeholder: "hewwo world"
|
||||||
|
}.render().expect("Failed to render index.html");
|
||||||
|
|
||||||
|
Ok(Html(html))
|
||||||
|
}
|
||||||
|
|
7
src/public/templates.rs
Normal file
7
src/public/templates.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use askama::Template;
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "index.html")]
|
||||||
|
pub struct IndexTemplate<'a> {
|
||||||
|
placeholder: &'a str,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user