Because I find a good alternate--Mongoose, which is small, no dependency, cross-platform, and written by pure C. Maybe you should consider use it.
Lhttpd is a C library to take care of the detail about TCP and HTTP, and it's API is designed for ease of use, so you can focus on business logic.
- Asynchronous.
- Lightweight and easy to use.
- Provide TCP support and some webserver functionality.
- Simple bottle-like web route support.
- JSON support.
- Redis support.
- SQLite3 support.
- NOT thread-safe.
# compile, generate `liblhttpd.xxx` and `lhttpd.h`, and move they to `/usr/local/lib` and `/usr/local/include`
./install.sh
NOTE: If you are linux user, please run below commands to update shared libraries before using lhttpd
.
# You should use root user
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
You need cmake and make for build, and below libraries for compile.
- Required: libuv.
- Optional: json-c for json support.
- Optional: sqlite3 for sqlite support.
- Optional: redis and hiredis for redis support.
- Optional: grequests for test.
- Optional: valgrind for memory leak check and siege for pressure test.
# cmake and make
sudo apt-get install cmake make
# libuv
git clone https://github.com/libuv/libuv.git
cd libuv
sh autogen.sh && sh autogen.sh
./configure
make
make check
sudo make install
# json-c
sudo apt-get install libjson0 libjson0-dev
# sqlite3
sudo apt-get install sqlite3 libsqlite3-dev
# redis
sudo apt-get install redis-server
# hiredis
git clone https://github.com/redis/hiredis.git
cd hiredis
make
sudo make install
# grequests
sudo pip install grequests
modify adapters/libuv.h
as follow and try again:
- add
#include <stdlib.h>
to first line. - find
static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop)
and deletestatic
.
see examples or test for details.
./install.sh examples
./install.sh test
see defines in lhttpd.in.h.
Inspired by the bottle.
MIT