Created
December 20, 2018 22:03
-
-
Save codesections/cccbd299f11e16e4e9c9fb53101b1ced to your computer and use it in GitHub Desktop.
Basic static file server with actix-web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate actix_web; | |
use actix_web::{fs, server, App}; | |
fn main() { | |
server::new(|| { | |
App::new() | |
.handler( | |
"/", | |
fs::StaticFiles::new("./public") | |
.unwrap() | |
.show_files_listing(), | |
) | |
.finish() | |
}) | |
.workers(1) | |
.bind("127.0.0.1:8000") | |
.expect("Can not bind to port 8000") | |
.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment