From e58403f3b9c4c8686537c4716a6ed3f65ca48370 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Sun, 21 Feb 2021 22:03:59 -0500 Subject: init upload --- .gitignore | 5 +++++ Cargo.toml | 16 ++++++++++++++++ src/main.rs | 39 +++++++++++++++++++++++++++++++++++++++ src/templates/index.html | 10 ++++++++++ 4 files changed, 70 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100644 src/templates/index.html diff --git a/.gitignore b/.gitignore index 8ffd9f4..422814a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,8 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk + + +#Added by cargo + +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..cdc7820 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "twinh" +version = "0.1.0" +authors = ["Adam T. Carpenter "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +handlebars = "3.5" +hyper = { version = "0.14", default-features = false, features = ["full"] } +mongodb = "1.2" +once_cell = "1.5" +serde = "1.0" +serde_json = "1.0" +tokio = { version = "1", default-features = false, features = ["full"] } diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9d4a4f4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,39 @@ +use hyper::service::{make_service_fn, service_fn}; +use hyper::{Body, Request, Response, Server}; +use std::convert::Infallible; +use std::net::SocketAddr; + +#[tokio::main] +async fn main() { + // We'll bind to 127.0.0.1:3000 + let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); + + // A `Service` is needed for every connection, so this + // creates one from our `hello_world` function. + let make_svc = make_service_fn(|_conn| async { + // service_fn converts our function into a `Service` + Ok::<_, Infallible>(service_fn(hello_world)) + }); + + // And construct the `Server` like normal... + let server = Server::bind(&addr).serve(make_svc); + + // And now add a graceful shutdown signal... + let graceful = server.with_graceful_shutdown(shutdown_signal()); + + // Run this server for... forever! + if let Err(e) = graceful.await { + eprintln!("server error: {}", e); + } +} + +async fn hello_world(_req: Request) -> Result, Infallible> { + Ok(Response::new("Hello, World".into())) +} + +async fn shutdown_signal() { + // Wait for the CTRL+C signal + tokio::signal::ctrl_c() + .await + .expect("failed to install CTRL+C signal handler"); +} diff --git a/src/templates/index.html b/src/templates/index.html new file mode 100644 index 0000000..7b6070c --- /dev/null +++ b/src/templates/index.html @@ -0,0 +1,10 @@ + + + +
    +
  • Essex
  • +
  • Hudson
  • +
  • Terraplane
  • +
+ + -- cgit v1.2.3