Skip to content

superbogy/lhttpd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

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

Travis Build Status

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.

Features

  • 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.

Build and Install

Install

# 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

Dependency

You need cmake and make for build, and below libraries for compile.

Required

# 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

Optional

# 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

If install hiredis error

modify adapters/libuv.h as follow and try again:

  1. add #include <stdlib.h> to first line.
  2. find static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop) and delete static.

Usage

see examples or test for details.

./install.sh examples
./install.sh test

API

see defines in lhttpd.in.h.

Request Routing

Inspired by the bottle.

LICENSE

MIT

About

Lightweight http server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 96.1%
  • Python 1.8%
  • CMake 1.5%
  • Shell 0.6%