1 extern crate actix_web
;
5 use actix_web
::{web
, middleware
, App
, HttpServer
, HttpResponse
, Responder
, Result
, web
::Query
};
7 use serde
::{Deserialize}
;
10 #[template(path = "main.html")]
11 struct MainTemplate
<'a
> {
15 #[derive(Deserialize)]
20 fn main_page(query
: Query
<Request
>) -> Result
<HttpResponse
> {
24 None
=> "Marc, roule un pet'!"
27 let hello
= MainTemplate
{ sentence
: m
};
29 let s
= hello
.render().unwrap();
30 Ok(HttpResponse
::Ok().content_type("text/html").body(s
))
33 fn main() -> std
::io
::Result
<()> {
37 .wrap(middleware
::Compress
::default())
38 .wrap(middleware
::Logger
::default())
39 .service(web
::resource("/").to(main_page
))
40 .service(fs
::Files
::new("/static", "static").show_files_listing())
44 .expect("Can not bind to port 8082")