A lightweight, fast, and simple HTTP server written in C++. This project demonstrates how to handle HTTP requests and responses using basic networking features in C++.
- Transmits hello world html page as a response to client.
- Able to load the style.css and script.js
- Handles basic HTTP GET and POST requests.
- Supports basic routing and URL handling.
- Lightweight and minimalistic design, focused on performance.
- Easily extensible to support additional HTTP methods and features.
- C++17 or later
- A C++ compiler (GCC, Clang, MSVC, etc.), Only tested in GCC.
- Basic networking libraries like
iostream
,sys/socket.h
,netinet/in.h
, etc.
Make sure you have a C++17 compatible compiler installed (like GCC or Clang) and the required networking libraries are available.
- Clone this repository:
git clone https://github.com/The-Jat/CppWeb.git cd CppWebServer
- Build the project (using g++):
g++ -o server server.cpp
- Run the server:
./server
- Your HTTP server will start and listen on port 8080 by default. You can access it via a web browser or tools like curl:
-
or Visit the brower at this link: http://localhost:8080
curl http://localhost:8080
The server is up and running successfully, as shown in the following screenshot:
The browser is used as a client to make a request to the server. The following screenshot demonstrates the response: