From 58788947d3b54b87a9d79030167749d7caafb5a8 Mon Sep 17 00:00:00 2001 From: FunctionsAPI Date: Wed, 11 Jun 2025 14:28:28 +0000 Subject: [PATCH] Automatic push from FunctionsAPI --- README.md | 2 +- main.rs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 main.rs diff --git a/README.md b/README.md index 8e18871..14c0f3d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# b67fd3e848314c79947fe878ce916df5 +# 46cb9cb30fd348309af0f6c232b41057 diff --git a/main.rs b/main.rs new file mode 100644 index 0000000..6d32e40 --- /dev/null +++ b/main.rs @@ -0,0 +1,36 @@ +use axum::{Router, routing::get, Json}; +use serde::Serialize; +use std::net::SocketAddr; +use tokio::net::TcpListener; +#[derive(Serialize)] +struct Variables { + user_name: String, + age: i32, + is_student: bool, + score: f32, +} +async fn display_variables() -> Json { + // Declare and assign variables of different types + let user_name = String::from("Alice"); + let age = 25; + let is_student = true; + let score = 95.5; + // Return variables as JSON + Json(Variables { + user_name, + age, + is_student, + score, + }) +} +#[tokio::main] +async fn main() { + // Create Axum router with a single route + let router = Router::new().route("/variables", get(display_variables)); + // Set up server address and port + let addr = SocketAddr::from(([0, 0, 0, 0], 8080)); + let tcp = TcpListener::bind(&addr).await.unwrap(); + println!("Ready and listening on {}", addr); + // Start the server + axum::serve(tcp, router).await.unwrap(); +} \ No newline at end of file