1
0
mirror of https://github.com/actix/examples synced 2025-02-13 05:52:20 +01:00

20 lines
497 B
Rust
Raw Normal View History

2019-03-09 22:38:15 -08:00
use actix_files as fs;
use actix_web::{middleware, App, HttpServer};
2019-03-09 22:38:15 -08:00
fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
2019-03-09 22:38:15 -08:00
HttpServer::new(|| {
2018-05-20 21:03:29 -07:00
App::new()
2019-03-09 18:03:09 -08:00
// enable logger
2019-03-26 04:29:00 +01:00
.wrap(middleware::Logger::default())
2019-03-09 22:38:15 -08:00
.service(
// static files
fs::Files::new("/", "./static/").index_file("index.html"),
2018-05-20 21:03:29 -07:00
)
2019-03-09 18:03:09 -08:00
})
2019-03-09 22:38:15 -08:00
.bind("127.0.0.1:8080")?
.run()
}