hackathon_question1/
lib.rs

1extern crate reqwest;
2use std::collections::HashMap;
3extern crate serde;
4
5
6
7
8
9
10pub mod weather{
11
12pub fn textresponse() -> Result<(), Box<dyn std::error::Error>> {
13
14    
15    let resp = reqwest::blocking::get("http://api.weatherapi.com/v1/current.json?key=3f3fc68039bb425d9bf213209200407&q=karachi
16    ")?
17        .text()?;
18    println!("{:#?}", resp);
19    Ok(())
20}
21
22// struct location{
23// name: String,
24// region: String,
25// country: String,
26// lat: u32,
27// lon: u32,
28// tz_id: String,
29// localtime_epoch: u32,
30// localtime: String,
31// }
32
33// struct current{
34//     temp_c: u8,
35    
36// }
37// #[derive(Deserialize)]
38// struct data{
39//     location:location,
40//     current:current,
41// }
42
43
44
45pub fn jsonresponse() -> Result<(), Box<dyn std::error::Error>> {
46    let resp = reqwest::blocking::get("http://api.weatherapi.com/v1/current.json?key=3f3fc68039bb425d9bf213209200407&q=karachi
47    ")?
48    .json()?;
49    
50    Ok(())
51}
52
53}
54
55
56