weatherstat/src/main.rs

20 lines
391 B
Rust
Raw Normal View History

#[macro_use]
extern crate rocket;
use dotenv::dotenv;
mod weather;
#[get("/weather/<loc>")]
async fn get_weather(loc: String) -> Result<String, String> {
let sum = weather::get_summary(&loc).await?;
Ok(format!("The weather in {} is: {:?}", loc, sum))
}
#[rocket::launch]
fn rocket() -> rocket::Rocket {
dotenv().ok();
rocket::ignite().mount("/", routes![get_weather])
2020-10-16 15:13:43 +02:00
}