Code Monkey home page Code Monkey logo

hi's Introduction

Introduction

A distribution of Nginx with c++ and python web development.

hi-nginx-image

hi_demo.

Dependency

  • linux
  • gcc,g++(c++11)
  • hiredis-devel
  • python-devel
  • boost-devel

Installation

see install_demo.sh or --add-module=ngx_http_hi_module

Features

  • All features of nginx(latest release) are inherited, i.e., it is 100% compatible with nginx.

Directives

  • directives : content: loc,if in loc

    • hi,default: ""

    example:

            location = /hello {
                hi hi/hello.so ;
            }
  • directives : content: http,srv,loc,if in loc ,if in srv

    • hi_need_cache,default: on

    example:

        hi_need_cache on|off;
  • directives : content: http,srv,loc,if in loc ,if in srv

    • hi_cache_size,default: 10

    example:

        hi_cache_size 10;
  • directives : content: http,srv,loc,if in loc ,if in srv

    • hi_cache_expires,default: 300s

    example:

        hi_cache_expires 300s;
  • directives : content: http,srv,loc,if in loc ,if in srv
    • hi_need_headers,default: off

      example:

        hi_need_headers on|off;
  • directives : content: http,srv,loc,if in loc ,if in srv
    • hi_need_cookies,default: off

      example:

        hi_need_cookies on|off;
  • directives : content: http,srv,loc,if in loc ,if in srv
    • hi_need_session,default: off

      example:

        hi_need_session on|off;
  • directives : content: http,srv,loc,if in loc ,if in srv

    • hi_session_expires,default: 300s

    example:

        hi_session_expires 300s;
  • directives : content: http,srv,loc,if in loc ,if in srv

    • hi_redis_host,default: ""

    example:

        hi_redis_host 127.0.0.1;
  • directives : content: http,srv,loc,if in loc ,if in srv

    • hi_redis_port,default: 0

    example:

        hi_redis_port 6379;
  • directives : content: loc,if in loc

    • hi_python_content,default: ""

    example:

            location = /pyecho {
                hi_python_content "hi_res.status(200)\nhi_res.content('hello,world')" ;
            }
  • directives : content: loc,if in loc

    • hi_python_srcipt,default: ""

    example:

            location ~ \.py$  {
                hi_python_script python;
            }

python api

hi_req

  • uri
  • method
  • client
  • param
  • user_agent
  • has_header
  • get_header
  • has_form
  • get_form
  • has_session
  • get_session
  • has_cookie
  • get_cookie

hi_res

  • status
  • content
  • header
  • session

hello,world

class

#include "servlet.hpp"
namespace hi{
class hello : public servlet {
    public:

        void handler(request& req, response& res) {
            res.headers.find("Content-Type")->second = "text/plain;charset=UTF-8";
            res.content = "hello,world";
            res.status = 200;
        }

    };
}

extern "C" hi::servlet* create() {
    return new hi::hello();
}

extern "C" void destroy(hi::servlet* p) {
    delete p;
}

compile

g++ -std=c++11 -I/home/centos7/nginx/include  -shared -fPIC hello.cpp -o hello.so
install hello.so /home/centos7/nginx/hi

nginx.conf

hi_demo_conf

hi's People

Watchers

 avatar  avatar

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.