adapt to new httpserver
This commit is contained in:
parent
e9775acdba
commit
083a803bab
1 changed files with 10 additions and 16 deletions
26
server.spl
26
server.spl
|
@ -1,4 +1,5 @@
|
|||
"#http/server.spl" import
|
||||
"#httpserver/base.spl" import
|
||||
"#httpserver/static.spl" import
|
||||
|
||||
func destub { html | with html title ;
|
||||
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 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 index.html "index.html" read-file destub<"Home"> =index.html
|
||||
|
@ -40,19 +40,13 @@ func main { mega | with args ;
|
|||
}
|
||||
|
||||
func handle-client { | with client ;
|
||||
client:path "/" eq if {
|
||||
index.html client:write-ok:write-html-body:finish;
|
||||
2 stop
|
||||
client
|
||||
:serve-html-string<index.html "/">
|
||||
:serve-html-string<features.html "/features">
|
||||
:serve-file-cached<"style.css" "/style.css" "text/css">
|
||||
:is-open
|
||||
if {
|
||||
404.html client:write-head<404 "Not found">:write-html-body:finish;
|
||||
}
|
||||
client:path "/features" eq if {
|
||||
features.html client:write-ok:write-html-body:finish;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue