2019-03-29 13:48:31 +00:00
|
|
|
extern crate actix;
|
|
|
|
|
extern crate actix_web;
|
|
|
|
|
extern crate webterm;
|
|
|
|
|
|
2019-03-29 16:51:42 +00:00
|
|
|
use actix_web::{fs::StaticFiles, server, App};
|
2019-03-29 13:48:31 +00:00
|
|
|
use webterm::WebTermExt;
|
|
|
|
|
|
2019-03-29 15:32:35 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
2019-03-29 13:48:31 +00:00
|
|
|
fn main() {
|
|
|
|
|
pretty_env_logger::init();
|
|
|
|
|
|
|
|
|
|
server::new(|| {
|
|
|
|
|
App::new()
|
|
|
|
|
.handler(
|
|
|
|
|
"/static",
|
|
|
|
|
StaticFiles::new("node_modules")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.show_files_listing(),
|
|
|
|
|
)
|
2019-03-29 15:32:35 +00:00
|
|
|
.webterm_socket("/websocket", |_req| {
|
|
|
|
|
let mut cmd = Command::new("/bin/sh");
|
|
|
|
|
cmd.env("TERM", "xterm");
|
|
|
|
|
cmd
|
|
|
|
|
})
|
2019-03-29 16:51:42 +00:00
|
|
|
.webterm_ui("/", "/websocket", "/static")
|
2019-03-29 13:48:31 +00:00
|
|
|
})
|
|
|
|
|
.bind("127.0.0.1:8080")
|
|
|
|
|
.unwrap()
|
|
|
|
|
.run();
|
|
|
|
|
}
|