A lightweight HTTP web server built with C++ and the cpp-httplib library.
This repository is a learning-friendly, stepwise web development guide using C++ and cpp-httplib.
| Step | Folder | Topic |
|---|---|---|
| 01 | step01_hello_world/ | Basic Web Server in C++ |
| 02 | step02_static_html_css/ | Serve HTML + CSS |
| 03 | step03_json_api/ | JSON API creation |
| 04 | step04_fetch_api/ | Frontend JS fetch |
| 05 | step05_dynamic_routes/ | Dynamic route handling |
| 06 | step06_query_params/ | Handle query strings |
| 07 | step07_mysql_connect/ | MySQL + C++ integration |
| 08 | step08_crud_api/ | CRUD operations via API |
| 09 | step09_crud_frontend/ | Connect CRUD to frontend |
| 10 | step10_form_handling/ | Handle form POST |
| 11 | step11_json_library/ | Use nlohmann/json |
| 12 | step12_authentication/ | Login system with API |
| 13 | step13_error_handling/ | Custom 404, 500 responses |
| 14 | step14_react_frontend/ | Use React as frontend |
| 15 | step15_modular_code/ | Clean architecture in C++ |
| 16 | step16_final_project/ | Build a complete web app |
cpp-web-server/
├── public/ # Frontend files (HTML, CSS)
│ ├── index.html
│ └── style.css
├── src/ # C++ source code
│ └── server.cpp
├── httplib.h # Header-only web server library
├── .gitignore
└── README.md # Project documentation
Compile the server:
g++ -std=c++17 src/server.cpp -o server.exe -lws2_32Start the server:
./server.exeOpen in browser::
http://localhost:8080- Tested on
Windows with MinGW - Use
-lws2_32 flagfor compiling onWindows
- This playground is designed for step-by-step mastery of C++ web backend development.
- Each folder is a self-contained lesson you can compile and run independently.
- Feel free to explore, modify, and learn at your own pace!