implement SimpleServer
This commit is contained in:
parent
0d34caebe4
commit
c3e4bc1197
1 changed files with 18 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
"#httpserver/static.spl" import
|
"#httpserver/static.spl" import
|
||||||
|
|
||||||
use net:http:Server
|
use net:http:Server
|
||||||
|
1048576 net:http:server:=bufsize
|
||||||
|
|
||||||
construct Latest {
|
construct Latest {
|
||||||
release
|
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 ;
|
func props-to-json { | with props ;
|
||||||
"{"
|
"{"
|
||||||
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;
|
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 {
|
client:wrote-body not if {
|
||||||
Object404:new client:write-head<404 "Not Found">:write-content-type<"application/json">:write-str-body:finish;
|
Object404:new client:write-head<404 "Not Found">:write-content-type<"application/json">:write-str-body:finish;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue