Skip to content

Instantly share code, notes, and snippets.

@espeon
Created June 7, 2020 05:14
Show Gist options
  • Select an option

  • Save espeon/0f8001365bb981ed97acb4e033bf15b7 to your computer and use it in GitHub Desktop.

Select an option

Save espeon/0f8001365bb981ed97acb4e033bf15b7 to your computer and use it in GitHub Desktop.
use dotenv;
use warp::Filter;
#[tokio::main]
async fn main() {
dotenv::dotenv().ok();
let hello = warp::any().map(|| {
"Hello from warp!"
});
let hello_from_warp = warp::path!("img" / u32 / u32).map(|x,y| {
format!("Your lucky numbers are {} and {}",x, y)
});
let routes = hello_from_warp.or(hello);
warp::serve(routes).run(([188, 165, 236, 229], 3030)).await;
println!("Hey! Open up localhost:3030 in your browser!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment