adapt to new httpserver

This commit is contained in:
Daniella / Tove 2024-09-23 15:45:20 +02:00
parent e9775acdba
commit 083a803bab

View file

@ -1,4 +1,5 @@
"#http/server.spl" import "#httpserver/base.spl" import
"#httpserver/static.spl" import
func destub { html | with html title ; func destub { html | with html title ;
stub.html stub.html
@ -10,7 +11,6 @@ func destub { html | with html title ;
def lorem-ipsum "lorem-ipsum" read-file:replace<"\n" "<br>"> =lorem-ipsum def lorem-ipsum "lorem-ipsum" read-file:replace<"\n" "<br>"> =lorem-ipsum
def stub.html "stub.html" read-file =stub.html def stub.html "stub.html" read-file =stub.html
def style.css "style.css" read-file =style.css
def 404.html "404.html" read-file destub<"404"> =404.html def 404.html "404.html" read-file destub<"404"> =404.html
def index.html "index.html" read-file destub<"Home"> =index.html def index.html "index.html" read-file destub<"Home"> =index.html
@ -40,19 +40,13 @@ func main { mega | with args ;
} }
func handle-client { | with client ; func handle-client { | with client ;
client:path "/" eq if { client
index.html client:write-ok:write-html-body:finish; :serve-html-string<index.html "/">
2 stop :serve-html-string<features.html "/features">
} :serve-file-cached<"style.css" "/style.css" "text/css">
client:path "/features" eq if { :is-open
features.html client:write-ok:write-html-body:finish; if {
2 stop
}
client:path "/style.css" eq if {
style.css client:write-ok:write-content-type<"text/css">:write-str-body:finish;
2 stop
}
404.html client:write-head<404 "Not found">:write-html-body:finish; 404.html client:write-head<404 "Not found">:write-html-body:finish;
} }
}