一直在看aardio的代码, 最近看到一个form嵌入echarts图表的例子,感觉还不错, 但从远端下载echarts.min.js不稳定,偶尔会无法展示,于是就弄了个nginx来本地下载js的方式, 展示效果还不错. 见此: https://gitee.com/wmhx/aardio_project/tree/master/echarts
但aardio自己也有httpserver, 于是又写了一点代码来内嵌一个httpserver的方式来提供js下载服务, 代码如下, 没有全部整合.
//多线程HTTP服务器
import fsys;
import process;
import wsock.tcp.simpleHttpServer;
var server = wsock.tcp.simpleHttpServer( "127.0.0.1" ,/*随机端口*/ );
server.documentRoot= ..fsys.getCurDir();
var ip,port=server.getLocalIp();
var url = ..string.format("http://%s:%d",ip,port );
process.execute(server.getUrl()); //用浏览器打开
server.run(
function(response,request,session){
var file=..io.fullpath(..fsys.getCurDir(),request.path);
if(..io.exist(file)) {
if(..fsys.isDir(file)){
response.write( time.now() );
} else {
var strData = ..string.load(file);
response.contentType = ..fsys.mime.fromFile(file);
response.write(strData)
}
}
else { response.errorStatus(404); }
}
)
return {
ip=ip;
port=port;
url=url;
}