TinyWeb is a simple HTTP web server written in C that handles basic HTTP requests on port 80 and serves static files from a configurable directory (./webroot).
It’s perfect for learning and experimenting with sockets, file handling, and network programming in C.
- Handles HTTP GET requests on port 80
- Serves static files from the
webrootdirectory - Supports sequential multiple connections
- Returns 404 responses for missing files
- Minimalistic, straightforward, and easy-to-understand implementation
- Compatible C compiler (gcc, clang)
- Unix-like system (Linux, macOS) recommended
- Network configured to allow connections on port 80
Clone the repository and compile:
git clone https://github.com/yourusername/tinyweb.git
cd tinyweb
gcc -o tinyweb tinyweb.cRun the server as root (port 80 requires elevated privileges):
sudo ./tinywebThe server will start listening for HTTP connections on port 80. Place your HTML files and other resources inside the webroot folder.
Open your browser and visit:
http://localhost
You should see the index.html file served from the webroot directory. If it does not exist, a 404 response will be returned.
- Change the port and root directory by editing the macros at the top of
main.c. - Add support for multiple MIME types for different file extensions.
- Implement threading for concurrent connections.
Contributions are welcome! Fork the repo, add your feature or fix, and submit a Pull Request.
Miguel Araújo Julio LinkedIn | GitHub | [email protected]
Thank you for checking out TinyWeb! Feel free to reach out with questions, suggestions, or collaboration ideas.