You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
979B

  1. extern crate actix;
  2. extern crate actix_web;
  3. extern crate env_logger;
  4. use actix_web::http::{header, Method};
  5. use actix_web::{
  6. fs, middleware, server, App, HttpResponse,
  7. };
  8. fn main() {
  9. ::std::env::set_var("RUST_LOG", "actix_web=info");
  10. env_logger::init();
  11. let sys = actix::System::new("sokoban-server");
  12. server::new(|| {
  13. App::new()
  14. // enable logger
  15. .middleware(middleware::Logger::default())
  16. // redirect
  17. // .resource("/", |r| r.method(Method::GET).f(|_req| {
  18. // HttpResponse::Found()
  19. // .header(header::LOCATION, "../client/index.html")
  20. // .finish()
  21. // }))
  22. // static files
  23. .handler("/", fs::StaticFiles::new("../client/web").unwrap())
  24. }).bind("127.0.0.1:8080")
  25. .unwrap()
  26. .shutdown_timeout(1)
  27. .start();
  28. println!("Started http server: 127.0.0.1:8080");
  29. let _ = sys.run();
  30. }