1
0
mirror of https://github.com/actix/examples synced 2025-06-28 18:00:37 +02:00

Adding first draft of static index example

This commit is contained in:
Jose Marinez
2018-04-16 16:38:29 -04:00
parent 447ee25869
commit 6276b697e2
9 changed files with 161 additions and 0 deletions

32
static_index/src/main.rs Normal file
View File

@ -0,0 +1,32 @@
extern crate actix;
extern crate actix_web;
extern crate env_logger;
use actix_web::{fs, App, server, middleware};
fn main() {
::std::env::set_var("RUST_LOG", "actix_web=info");
::std::env::set_var("RUST_BACKTRACE", "1");
env_logger::init();
let sys = actix::System::new("static_index");
server::new(
|| App::new()
// enable logger
.middleware(middleware::Logger::default())
.handler(
"/",
fs::StaticFiles::new("./static/").index_file("index.html")
)
)
.bind("127.0.0.1:8080").expect( "Can not start server on given IP/Port" )
.start();
println!("Started http server: 127.0.0.1:8080");
let _ = sys.run();
}