mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +01:00
add logger for askama template example (#466)
This commit is contained in:
parent
e0e1c9b31f
commit
ba5ab96897
@ -5,6 +5,7 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
env_logger = "0.8"
|
||||||
actix-web = "3"
|
actix-web = "3"
|
||||||
askama = "0.9"
|
askama = "0.9"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use actix_web::{web, App, HttpResponse, HttpServer, Result};
|
use actix_web::{middleware, web, App, HttpResponse, HttpServer, Result};
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
@ -30,9 +30,14 @@ async fn index(query: web::Query<HashMap<String, String>>) -> Result<HttpRespons
|
|||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||||
|
env_logger::init();
|
||||||
|
|
||||||
// start http server
|
// start http server
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new().service(web::resource("/").route(web::get().to(index)))
|
App::new()
|
||||||
|
.wrap(middleware::Logger::default())
|
||||||
|
.service(web::resource("/").route(web::get().to(index)))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("127.0.0.1:8080")?
|
||||||
.run()
|
.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user