summaryrefslogtreecommitdiff
path: root/actix/src/main.rs
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-03-06 20:51:23 +0100
committerxengineering <mail2xengineering@protonmail.com>2021-03-06 20:51:23 +0100
commitf48ce5deb19d83e6d5e87f51c59e538f4b66d79e (patch)
treed95ac46c757c4506044fbb4e0469ecadf3f78ef7 /actix/src/main.rs
parentf9714353664507845bad9e5856f5396ab3d629b2 (diff)
downloadweb-template-f48ce5deb19d83e6d5e87f51c59e538f4b66d79e.tar
web-template-f48ce5deb19d83e6d5e87f51c59e538f4b66d79e.tar.zst
web-template-f48ce5deb19d83e6d5e87f51c59e538f4b66d79e.zip
Switch back to Flask
Diffstat (limited to 'actix/src/main.rs')
-rw-r--r--actix/src/main.rs65
1 files changed, 0 insertions, 65 deletions
diff --git a/actix/src/main.rs b/actix/src/main.rs
deleted file mode 100644
index 90988c4..0000000
--- a/actix/src/main.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-// vim: tabstop=4 shiftwidth=4 expandtab
-
-
-use std::fs;
-extern crate clap;
-use actix_files;
-use actix_web::{get, App, HttpResponse, HttpServer, Responder};
-
-
-#[derive(Debug)]
-struct RuntimeConfig {
- address: String,
- port: String,
-}
-
-
-#[actix_web::main]
-async fn main() -> std::io::Result<()> {
-
- let cfg = get_runtime_config();
-
- println!("Binding to http://{}:{}", cfg.address, cfg.port);
-
- HttpServer::new(|| {
- App::new()
- .service(index)
- .service(actix_files::Files::new("/static", "./static")) // you may append .show_files_listing()
- })
- .bind(format!("{}:{}", cfg.address, cfg.port))?
- .run()
- .await
-}
-
-fn get_runtime_config() -> RuntimeConfig {
-
- let cli_matches = clap::App::new("Actix Web Server")
- .about("Executable to run the web-template Web Server")
- .arg(clap::Arg::with_name("address")
- .help("The address to which the server binds")
- .long("address")
- .short("a")
- .takes_value(true)
- .default_value("127.0.0.1"))
- .arg(clap::Arg::with_name("port")
- .help("The port to which the server binds")
- .long("port")
- .short("p")
- .takes_value(true)
- .default_value("8080"))
- .get_matches();
-
- RuntimeConfig {
- address: cli_matches.value_of("address").unwrap().to_string(),
- port: cli_matches.value_of("port").unwrap().to_string(),
- }
-}
-
-#[get("/")]
-async fn index() -> impl Responder {
- HttpResponse::Ok()
- .content_type("text/html")
- .body(fs::read_to_string("./static/index.html").unwrap())
-
-}
-