LightHop is a lightweight HTTP static file server written in modern C++.
It listens on a TCP port, accepts incoming HTTP requests, and serves files from a configurable directory — with a focus on simplicity, performance, and clarity.
- ⚡ Built with modern C++ (
C++23) and CMake - 🔄 Poll-based event loop for handling multiple clients
- 📁 Static file serving from a configurable
wwwdirectory - 🌐 Automatic MIME type detection for common file types
- ⚙️ YAML-based configuration (
config.yml) with safe defaults - 🪵 Colored runtime logging with timestamps
- CMake 3.20+
- C++ compiler with C++23 support
yaml-cpp(resolved viafind_package)- POSIX-compatible system (
poll,netinet,unistd, etc.)
From the project root:
cmake -S . -B build
cmake --build buildThe executable will be located in:
./build/LightHopBefore starting, optionally adjust config.yml.
./build/LightHopBy default:
- 🌐 Port:
8080 - 📁 Directory:
www/
LightHop reads settings from config.yml at startup.
If the file is missing or invalid, default values are used.
| Key | Description | Default |
|---|---|---|
port |
Server port (0–65535) |
8080 |
www-dir |
Directory for static files | www/ |
poll-timeout |
Poll timeout in ms (-1 = block) |
-1 |
socket-backlog |
Pending connection queue size | 10 |
buffer-size |
Per-client read buffer size (bytes) | 4096 |
- If
www-dirdoes not exist, it will be created automatically - Requesting
/servesindex.html
LightHop/
├── include/
│ ├── client.h
│ ├── config.h
│ ├── file_reader.h
│ ├── http_response.h
│ ├── logger.h
│ └── server.h
├── src/
│ ├── client.cpp
│ ├── config.cpp
│ ├── file_reader.cpp
│ ├── http_response.cpp
│ ├── main.cpp
│ └── server.cpp
├── config.yml
└── CMakeLists.txt
- Serves static files over HTTP
- Returns
404 Not Foundfor missing resources - Focused on a minimal, clear HTTP response pipeline
- Improve HTTP request parsing and validation
- Add unit and integration tests
- Implement graceful shutdown and signal handling
- Add optional routing and middleware-like extensions
Contributions are welcome:
- Fork the repository
- Create a feature branch
- Commit changes with clear messages
- Open a pull request with a short description
MIT License
Copyright (c) 2026 Angel Maya
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.