Axum - Hello World !

yellowcoderyellowcoder
1 min read

Axum is a web application framework that focuses on ergonomics and modularity.

This yellowcoder-tibbit tells you about a simple Axum - “Hello World!” examples you can get quickly started with by following steps given in repo.

use axum::{response::Html, routing::get, Router};

#[tokio::main]
async fn main() {

    let app = Router::new().route("/",get(||async {
        Html("
            <h1>Hello World</h1>
            <h2>Here Rust Server is running....</h2>
            Author: <strong>Yellow Coder</strong>
            ")

    }));

    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await.unwrap();

    axum::serve(listener,app).await.unwrap();
}
0
Subscribe to my newsletter

Read articles from yellowcoder directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

yellowcoder
yellowcoder