hi-nginx-1.7.8 发布,嵌入duktape引擎,支持js开发

栏目: JavaScript · 发布时间: 7年前

内容简介:hi-nginx-1.7.8发布了。这一次更新的重点嵌入javascript引擎duktape,因而支持使用js进行web应用开发。通过以下四个命令开启duktape支持:duktape web开发的接口与python和lua保持一致。例子:

hi-nginx-1.7.8发布了。

这一次更新的重点嵌入javascript引擎duktape,因而支持使用js进行web应用开发。通过以下四个命令开启duktape支持:

  • hi_duktape_package_path 配置js文件模块搜索路径(js模块写法与nodejs一致)

  • hi_duktape_package_cpath 配置动态库模块搜索路径(动态库模块基于duktape c接口,但可以同时支持c++)

  • hi_duktape_content 运行js内容块

  • hi_duktape_script 运行js文件

duktape web开发的接口与 pythonlua 保持一致。例子:

/*
 var foo = require('foo')
 hi_res.header('Content-Type','text/plain;charset=UTF-8')
 hi_res.content(foo.hello())
 hi_res.status(200)
*/


/*
 var mustache = require('mustache')
 var template = '<h1>Test mustache engine</h1><p>{{body}}</p>';
 var model = {body:'Hello World'};
 hi_res.content(mustache.to_html(template,model))
 hi_res.status(200)
 */

/*
 var handlebars = require('handlebars')
 var template = handlebars.compile('<h1>Test handlebars engine</h1><p>{{body}}</p>')
 var model = {body:'Hello World'};
 hi_res.content(template(model))
 hi_res.status(200)
 */


/*
 var echo = require('echo')
 var t=new echo()
 t.set('HELLO, ')
 hi_res.content(t.concat('Tom'))
 hi_res.status(200)
 */



/*

var route = require('route').get_instance()

route.get('^\/get/?(\\w+)$', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.post('^\/post/?([a-zA-Z]+)?$', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.put('^\/put/?([0-9]+)?', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.add(['GET', 'POST', 'PUT'], '^\/(.*)$', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.run(hi_req, hi_res)


*/

/*

var loaded = hi_module.require('demo', 'cpp')
var registered = cpp()
if (loaded && registered) {
    var a = new demo()
    hi_res.header('Content-Type', 'text/plain;charset=UTF-8')
    hi_res.content(a.echo('hello,cpp class'))
    hi_res.status(200)
    hi_module.free(a)
}

*/

///*
 hi_res.header('Content-Type','text/plain;charset=UTF-8')
 hi_res.content('hello,world')
 hi_res.status(200)
//*/

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Kotlin程序员面试算法宝典

Kotlin程序员面试算法宝典

孙伟、楚秦 / 机械工业出版社 / 2018-12 / 69

本书是一本讲解程序员面试笔试算法的书籍。在写法上,除了讲解如何解答算法问题以外,还引入了例子辅以说明,以便读者能够更加容易地理解。 本书将程序员面试笔试过程中的各类算法类真题一网打尽。在题目的广度上,通过各种渠道,搜集了近3年来几乎所有IT企业面试笔试算法高频题目,所选择题目均为企业招聘使用题目;在题目的深度上,本书由浅入深、庖丁解牛式地分析每一个题目,并提炼归纳,同时,引入例子与源代码、时......一起来看看 《Kotlin程序员面试算法宝典》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试