use base64::Engine;
use dotenvy_macro::dotenv;
use flopper::flop;
use tracing::{info, Level};
use tracing_subscriber::FmtSubscriber;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let key: &str = dotenv!("KEY");
let secret: &str = dotenv!("SECRET");
tracing::subscriber::set_global_default(
FmtSubscriber::builder()
.with_max_level(Level::INFO)
.pretty()
.without_time()
.finish(),
)
.expect("Fail to set global default subscriber");
info!("Fetch images using flop!");
let images = flop!(
key,
secret,
n = 1, w = 512, h = 512, q = "forest".to_string(), m = 4 );
info!("convert from base64 to png");
let image = base64::engine::general_purpose::STANDARD.decode(images[0].clone())?;
info!("write to test_image.png");
std::fs::write("test_image.png", image)?;
info!("Done!");
Ok(())
}