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开发的接口与 python 和 lua 保持一致。例子:
/*
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)
//*/
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- QuickJS,一个小型并且可嵌入的 Javascript 引擎
- 用go来做嵌入式开发-嵌入资源简化程序部署
- ActiveMQ嵌入Tomcat
- 词嵌入的那些事儿(一)
- 嵌入式Python环境
- 嵌入式系统(Linux)优化
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。