simple_example/
simple_example.rs

1//! A simple example, assuming you had a config.json file that had your api key.
2
3use rustnao::{HandlerBuilder, Sauce};
4
5fn main() {
6    let data = std::fs::read_to_string("config.json").expect("Couldn't read file.");
7    let json: serde_json::Value =
8        serde_json::from_str(data.as_str()).expect("JSON not well formatted.");
9    let api_key = json["api_key"].as_str();
10    let file = "https://i.imgur.com/W42kkKS.jpg";
11
12    if let Some(key) = api_key {
13        let handle = HandlerBuilder::default().api_key(key).build();
14        let result: Vec<Sauce> = handle.get_sauce(file, None, None).unwrap();
15        for i in result {
16            println!("{:?}", i);
17        }
18    }
19}