This project is a basic HTTP server written in Rust. It listens for incoming HTTP requests on port 9999
and serves an index.html
file from the root directory. If the file is not found, it responds with a 404 Not Found error. This server is intended for educational purposes to demonstrate basic Rust programming concepts and network communication.
- Rust programming language (including Cargo, Rust's package manager and build tool).
To get a local copy up and running, follow these simple steps.
- Clone the repository to your local machine:
git clone https://your-repo-link-here
- Navigate to the project directory:
cd simple-rust-http-server
- Build and run the server with Cargo:
cargo run
-
Once the server is running, it will listen for HTTP requests on
localhost:9999
. -
To test the server, open a web browser and navigate to
http://localhost:9999
. You should see the contents of theindex.html
file displayed. Ifindex.html
does not exist, the server will respond with a 404 Not Found error.
Create an index.html
file in the root directory of the project with the following content for testing:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Rust HTTP Server</title>
</head>
<body>
<h1>Hello from Rust HTTP Server!</h1>
</body>
</html>
This server is a basic example for educational purposes and lacks many features and security measures required for a production environment. For real-world applications, consider using robust web frameworks and servers like Actix-web, Rocket, or Hyper.