Giter Club home page Giter Club logo

lhttpd's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.