Skip to content

onyangojerry/webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple Rust HTTP Server

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.

Prerequisites

Getting Started

To get a local copy up and running, follow these simple steps.

Installation

  1. Clone the repository to your local machine:
git clone https://your-repo-link-here
  1. Navigate to the project directory:
cd simple-rust-http-server

Running the Server

  1. Build and run the server with Cargo:
cargo run
  1. Once the server is running, it will listen for HTTP requests on localhost:9999.

  2. To test the server, open a web browser and navigate to http://localhost:9999. You should see the contents of the index.html file displayed. If index.html does not exist, the server will respond with a 404 Not Found error.

Adding index.html

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>

Note

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.


About

simple http webserver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published