Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Building a Simple Web Server | Rust Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Rust Fundamentals

Lesson 40 of 50

·rust

Building a Simple Web Server

25 minutes

Course progress80%

Building a Simple Web Server

Use the hyper crate to create an HTTP server.

[dependencies]
hyper = { version = \"0.14\", features = [\"full\"] }
use hyper::{Body, Request, Response, Server};
use hyper::service::{make_service_fn, service_fn};
use std::convert::Infallible;

  (_req: Request<Body>)  <Response<Body>, Infallible> {
    (Response::(Body::(\
async
fn
hello
->
Result
Ok
new
from
"Hello, Rust!\"))) } #[tokio::main] async fn main() { let make_svc = make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(hello)) }); let addr = \"127.0.0.1:3000\".parse().unwrap(); let server = Server::bind(&addr).serve(make_svc); println!(\"Listening on http://{}\", addr); if let Err(e) = server.await { eprintln!(\"server error: {}\", e); } }
Make it stickPractice what you've learned1 quiz · 1 practical test · Optional activities from Rust FundamentalsBrowse activities
Previous lessonForeign Function Interface (FFI)Continue to lesson 41Using Actix WebBack to Rust Fundamentals curriculum