implement SimpleServer

This commit is contained in:
Daniella / Tove 2024-10-13 23:22:10 +02:00
parent 0d34caebe4
commit c3e4bc1197
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -3,6 +3,7 @@
"#httpserver/static.spl" import
use net:http:Server
1048576 net:http:server:=bufsize
construct Latest {
release
@ -29,6 +30,15 @@ construct Object404 {
}
}
construct Refreshed {
ok
;
construct { this | with this ;
"true" this:=ok
this properties props-to-json
}
}
func props-to-json { | with props ;
"{"
props
@ -65,6 +75,14 @@ func handle-client { | with client ;
Latest:new client:write-ok:write-content-type<"application/json">:write-str-body:finish;
}
"/refresh" client:path eq if {
"refresh" println;
client:server:cached-files if {
client:server:cached-files:clear;
}
Refreshed:new client:write-ok:write-content-type<"application/json">:write-str-body:finish;
}
client:wrote-body not if {
Object404:new client:write-head<404 "Not Found">:write-content-type<"application/json">:write-str-body:finish;
}