Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loggerhead/lhttpd
Lightweight http server
https://github.com/loggerhead/lhttpd
Last synced: about 1 month ago
JSON representation
Lightweight http server
- Host: GitHub
- URL: https://github.com/loggerhead/lhttpd
- Owner: loggerhead
- License: mit
- Created: 2015-06-10T09:22:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T03:32:25.000Z (almost 8 years ago)
- Last Synced: 2023-08-05T17:11:15.651Z (over 1 year ago)
- Language: C
- Homepage:
- Size: 335 KB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEPRECATED
Because I find a good alternate--[Mongoose](https://github.com/cesanta/mongoose), which is small, no dependency, cross-platform, and written by pure C. Maybe you should consider use it.
# Lhttpd
[![Travis Build Status](https://travis-ci.org/loggerhead/lhttpd.svg)](https://travis-ci.org/loggerhead/lhttpd)
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](http://bottlepy.org/docs/dev/tutorial.html#request-routing) web route support.
* JSON support.
* Redis support.
* SQLite3 support.
* __NOT thread-safe__.# Build and Install
## Install```shell
# 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`.
```shell
# You should use root user
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
```## Dependency
You need [cmake](http://www.cmake.org/) and [make](http://www.gnu.org/software/make/) for build, and below libraries for compile.
* Required: [libuv](https://github.com/libuv/libuv).
* Optional: [json-c](https://github.com/json-c/json-c) for json support.
* Optional: [sqlite3](https://www.sqlite.org/) for sqlite support.
* Optional: [redis](https://github.com/antirez/redis) and [hiredis](https://github.com/redis/hiredis) for redis support.
* Optional: [grequests](https://github.com/kennethreitz/grequests) for test.
* Optional: [valgrind](http://valgrind.org/) for memory leak check and [siege](https://www.joedog.org/siege-home/) for pressure test.### Required
```shell
# 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
```shell
# 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 ` to first line.
2. find `static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop)` and delete `static`.# Usage
see [examples](https://github.com/loggerhead/lhttpd/tree/master/examples) or [test](https://github.com/loggerhead/lhttpd/tree/master/test) for details.
```shell
./install.sh examples
./install.sh test
```## API
see defines in [lhttpd.in.h](https://github.com/loggerhead/lhttpd/blob/master/include/lhttpd.in.h).
## Request Routing
Inspired by the [bottle](http://bottlepy.org/docs/dev/tutorial.html#request-routing).
# LICENSE
MIT