2020-10-16 17:12:14 +02:00
|
|
|
#[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
|
|
|
}
|