设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

通用服务器hi-nginx 1.4.2发布,多项重要更新

2018-4-3 23:04| 发布者: joejoe0332| 查看: 514| 评论: 0|原作者: oschina|来自: oschina

摘要: 支持多种编程语言混合开发 Web 应用的通用服务器hi-nginx-1.4.2已经发布了。此次发布包含多项重要更新:支持 Python 2 和 3,通过编译选项--with-http-hi-python-version删除 boost.python 依赖,优化 Python 3 兼容 ...

支持多种编程语言混合开发 Web 应用的通用服务器 hi-nginx-1.4.2 已经发布了。

此次发布包含多项重要更新:

  1. 支持 Python 2 和 3,通过编译选项--with-http-hi-python-version

  2. 删除 boost.python 依赖,优化 Python 3 兼容性,性能有所提高

  3. 支持 lua 和 luajit,通过编译选项 --with-http-hi-lua-version

  4. 为 Python 专门定制了 hi.py 框架,单一入口,类似 bottle 或者 flask 一样,对性能有一定影响,但还是比 bottle 和 flask 快得多

  5. 为 php7 专门定制了类似 hi.py 的微型框架,单一入口,类似 bottle 或者 flask 一样,对性能没什么影响

hi.py 示例:

from hi import hi
app =hi()

@app.route(r'^/test/?$',['GET','POST'])
@app.route(r"^/$",['GET'])
def hello_world(req,res,param):
    res.header('Content-Type','text/plain;charset=utf-8')
    res.content('hello,world')
    res.status(200)

@app.route(r"^/client/?$",['GET','POST'])
def client(req,res,param):
    res.content('{}<br>{}<br>{}<br>{}<br>{}'.format(req.client(),req.method(),req.uri(),req.user_agent(),req.param()))
    res.status(200)

@app.route(r"^/hello/(?P<who>\w+)?$",['GET'])
def hello(req,res,param):
    res.content('{}={}'.format('who',param['who']))
    res.status(200)



if __name__ == '__main__':
    app.run(hi_req,hi_res)

php7 示例:

require_once 'hi/servlet.php';
require_once 'hi/route.php';

class index implements \hi\servlet {

    public function handler(\hi\request $req, \hi\response $res) {
        $app = \hi\route::get_instance();
        $app->add('{^/$}'array('GET'), function ($rq, $rs, &$param) {
            $rs->content = 'hello,world';
            $rs->status = 200;
        });
        
        $app->add('{^/who/(?P<name>\w+)/?$}'array('GET'), function ($rq, $rs, &$param) {
            $rs->content = 'hello,'.$param['name'];
            $rs->status = 200;
        });

        $app->add('{^/phpinfo/?$}'array('GET'), function($rq, $rs, &$param) {
            ob_start();
            phpinfo();
            $rs->content = ob_get_contents();
            $rs->status = 200;
            ob_end_clean();
        });
        $app->run($req, $res);
    }

}

简介

它既是 web 服务器,也是 application 服务器。 

它是 NGINX 的超集。 

它性能强劲,易于开发,部署方便。 

它支持多种语言混合开发 web 应用:

  • C++

  • Python

  • Lua

  • Java

  • PHP

gitbook: https://doc.hi-nginx.com/

github: https://github.com/webcpp/hi-nginx


酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部