使用 aardio 中的 simpleHttpServer 库实现 python 例程中的 HTTP 服务器功能!
| 12
 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
 
 | 
 import console;
 import process;
 import wsock.tcp.simpleHttpServer;
 
 var srvHttp = wsock.tcp.simpleHttpServer()
 srvHttp.documentRoot = "d:\"
 
 console.log(srvHttp.getUrl());
 process.execute(srvHttp.getUrl());
 
 srvHttp.run(
 function(response,request){
 import fsys;
 import inet.url;
 
 if(!fsys.isDir(request.path) ) {
 if( ..io.exist(request.path) )
 response.loadcode(request.path)
 else {
 request.path = fsys.getParentDir(request.path)
 }
 }
 
 response.write(" <title>Directory listing for /</title>
 <body><h2>Directory listing for",request.path,"</h2><hr><ul>")
 
 var file,dir = fsys.list(request.path,,"*.*");
 for(i=1;#dir;1){
 response.write('<li><a href="'
 ,inet.url.append(request.path,dir[ i ])
 ,'">'+tostring(i)+") ",dir[ i ],'</a><br>\r\n');
 
 }
 
 for(i=1;#file;1){
 response.write('<li><a href="'
 ,inet.url.append(request.path,file[ i ])
 ,'">'+tostring(i)+") ",file[ i ],'</a><br>\r\n');
 
 }
 }
 )
 
 | 
用aardio实现python例程中的HTTP服务器功能