A webserver written completly in C with a basic build in templating system
10K+
A HTTP-Server completly written in ansi-C. Though it only works on linux at the moment.
Simply compile the code and execute the resulting binary to start a simple Webserver
To include a file you simply add <--include path="path to file"/> to your html file.
It will load the specified file and replace the tag with the content of said file.
Note: The path to the file has to start with a '/' otherwise it cant find it.
When a specified file can not be found it simply removes the tag.
'All' you need is to add the 'src/webserver' folder to your project and include the 'server.h' header, this should include everything you need
To create a Server you simple need to run:
int serverFd = createServer(port);
To then start the server up run:
startServer(serverFd);
Note: The startServer() function is going to block the Thread so if you want to have it in the background you need to execute it in another Thread.
setDebugMode(1);setGeneralCaching(1);setMeasureExec(1); (mostly only used in optimizing the webserver itself)setGeneralTemplateUsage(1); (this only affects the serving of static files)Note: This feature is still in development so it very likely still has some problems
To add a Custom Path simply run addCustomPath(Method, Path, function);
This will route every Request with the same Path as specified to the given function.
The function should look something like this
int name(request* req, response* resp);
and return a 0 if everything worked or a value that is not 0 if something went wrong
Content type
Image
Digest
Size
3.3 MB
Last updated
over 6 years ago
docker pull lol3r/c-http-server