This project is part of the 42 (1337) school curriculum. The goal is to create a simple HTTP web server in C++ that is compliant with a subset of the HTTP/1.1 protocol.
WebServ is a lightweight HTTP server built from scratch in C+ 7444 +. It is designed to handle basic HTTP requests and serve static files. This project aims to deepen understanding of network programming, HTTP protocol, and server-client architecture.
- HTTP/1.1 compliance
- GET, POST, and DELETE request handling
- Static file serving
- Basic CGI support
- Configurable through a configuration file
To install and build the WebServ project, follow these steps:
- Clone the repository:
git clone https://github.com/7h3Y055/WebServ.git
- Navigate to the project directory:
cd WebServ
- Build the project:
make
To start the server, run the following command:
./webserv [configuration_file]
If no configuration file is provided, the server will use the default settings.
The server can be configured using a configuration file. Below is an example configuration:
SERVER{
port = 8080
host=127.0.0.1
server_names=webserv
root=./www
error_page=404 error_pages/404.html
client_max_body_size= 10G
location / {
root=./www/cgi-bin/
index=README.html
}
location /cgi-bin {
methods=GET, POST, DELETE
directory_listing=ON
cgi=.py: /usr/bin/python3
}
}SERVER
To test the server, you can use tools like curl
or Postman
to send HTTP requests and verify the responses. Additionally, you can open a web browser and navigate to http://localhost:8080
to see the server in action.
Contributions are welcome! Please fork the repository and submit a pull request with your changes. Make sure to follow the coding standards and include tests for any new features or bug fixes.