A basic, lightweight web server built with Rust. This server listens on localhost at port 8080 and serves static HTML files in response to GET requests. It's designed as a simple example of handling HTTP requests in Rust.
- Simple Routing: Handles basic routing to serve different HTML pages based on the request URL.
- Multi-threaded: Utilizes Rust's
thread
module to handle connections concurrently. - Error Handling: Implements basic error handling for connection issues and file reading errors.
Ensure you have Rust installed on your system. You can download Rust and find installation instructions on the official Rust website.
- Clone the repository:
git clone git@github.com:renatodinizc/rust_web_server.git
- Navigate into the project directory:
cd rust_web_server
- Build and run the server:
cargo run
The server will start listening on localhost:8080
. You can access it using a web browser or a tool like curl
to make requests.
- www/: This directory contains the static HTML files served by the web server. Add your HTML files here.
index.html
: The default page served at/
.hello_world.html
: Example page served at/hello_world
.404.html
: Error page displayed when a request does not match existing routes.
With the server running, you can access the following URLs from a web browser:
http://localhost:8080/
- Displays the content ofindex.html
.http://localhost:8080/hello_world
- Displays the content ofhello_world.html
.- Any other path will result in a 404 page, showing the content of
404.html
.
Contributions are welcome! Feel free to open issues or submit pull requests to improve the server.
This project is licensed under the MIT License - see the LICENSE file for details.