2019-03-09 22:38:15 -08:00
|
|
|
use actix_files as fs;
|
|
|
|
use actix_web::{middleware, App, HttpServer};
|
2018-04-16 16:38:29 -04:00
|
|
|
|
2019-03-09 22:38:15 -08:00
|
|
|
fn main() -> std::io::Result<()> {
|
|
|
|
std::env::set_var("RUST_LOG", "actix_web=info");
|
2018-04-16 16:38:29 -04:00
|
|
|
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
|
|
|
|
.middleware(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()
|
2018-04-16 16:38:29 -04:00
|
|
|
}
|