tools/http.aardio
2024-06-08 20:40:51 +08:00

61 lines
1021 B
Plaintext

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add()
/*}}*/
import console;
import process;
import wsock.tcp.simpleHttpServer;
var server = wsock.tcp.simpleHttpServer()//"127.0.0.1",/*8081*/);
console.log( server.getUrl() )
process.execute( server.getUrl() );
//如果不需要窗口界面,那也可以直接使用 wsock.tcp.simpleHttpServer
server.run(
function(response,request,session){
if( io.exist( request.path,0)
&& request.path!="/main.aardio" ){
response.loadcode( request.path )
}
else{
loadcodex(`
<!doctype html>
<html><head></head><body style="white-space:pre"><?
response.jsonPrettyPrint = true;//输出缩进格式化的JSON
response.write(string.random(10));
?></body>
</html>`)
}
}
)
import win.timer
var timer = win.timer( winform );
timer.onTimer = function(hwnd,msg,id,tick){
server.publish("reload",)
}
//timer.setInterval(100)
timer.enable(100,100)
winform.show();
win.loopMessage();