diff --git a/src/bin/temp.rs b/src/bin/temp.rs index 5989701..c25231d 100644 --- a/src/bin/temp.rs +++ b/src/bin/temp.rs @@ -2,34 +2,35 @@ use std::collections::HashMap; use reqwest; use serde_json::json; -async fn run_async_code() -> Result<(), reqwest::Error> { +async fn compile_rust() -> Result<(), reqwest::Error> { let code = "//hello world! I'm Krusty the Krab and i like money lol. \n \n//Insert your rusty code over here and i will do the rest\n \n//Also,I tell NO to code that asks input from user \n \n \nfn main(){\n println!(6969696); //write code here\n}"; - let url = "https://play.rust-lang.org/execute"; + let url = "https://play.rust-lang.org/compile"; let mut data = HashMap::new(); data.insert("channel", "stable"); data.insert("mode", "debug"); - data.insert("edition", "2024"); + data.insert("edition", "2021"); data.insert("crateType", "bin"); data.insert("code", code); let client = reqwest::Client::new(); let res = client.post(url) - .header(reqwest::header::CONTENT_TYPE, "application/json") - .body(json!(data).to_string()) // Convert the HashMap to serde_json::Value using json!() - .send() - .await?; + .header(reqwest::header::CONTENT_TYPE, "application/json") + .json(&json!(data)) // Convert the HashMap to serde_json::Value using json!() + .send() + .await?; + +println!("{:?}", res); + - // Handle the response here - println!("{:?}", res); Ok(()) } #[tokio::main] async fn main() { - if let Err(err) = run_async_code().await { + if let Err(err) = compile_rust().await { // Handle the error here eprintln!("Error: {:?}", err); }