-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.aardio
53 lines (44 loc) · 1.14 KB
/
main.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
if( !request ){
/*
创建一个兼容FastCGI接口的简单Web服务器,如果已经在Web服务器环境下这段可以省略。
*/
import fsys.log;
import wsock.tcp.simpleHttpServer;
import process;
import console;
global.onError = function( err,over ){
if(!over){
import debug;
var stack = debug.traceback(,"调用栈",3);
err = ..string.concat(err,'\n',stack);
}
fsys.log.print( err );
}
var server = wsock.tcp.simpleHttpServer("127.0.0.1",60000);
console.setTitle("web服务器已启动 " + server.getUrl() );
//console.dump(server)
process.execute( server.getUrl() )
server.run(
function(response,request){
/*
//让浏览器识别为JSON
response.contentType = "text/json"
//让aardio输出JSON时美化格式
response.jsonPrettyPrint = true
//输出request对象(aardio会自动将对象转换为JSON)
response.write( request )
*/
/*
if (request.uri ="/") {
response.loadcode("index.aardio");
}
*/
response.loadcode(request.path);
}
);
return;
}
?>
<script language="javascript">
window.location = "light/index.aardio";
</script>