diff options
Diffstat (limited to 'user-programs')
| -rw-r--r-- | user-programs/folk-haip.local/web-endpoints.folk | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/user-programs/folk-haip.local/web-endpoints.folk b/user-programs/folk-haip.local/web-endpoints.folk index 274c350a..d9bd13e6 100644 --- a/user-programs/folk-haip.local/web-endpoints.folk +++ b/user-programs/folk-haip.local/web-endpoints.folk @@ -1,27 +1,28 @@ -Wish the Web server handles route "/static-html/$" with handler { - set html "<h1>Hello World!</h1>" +Wish the web server handles route "/static-html/$" with handler { + return [$html "<h1>Hello World!</h1>"] } -Wish the Web server handles route "/score/$" with handler { - set response [dict create contentType "application/json" body "{\"score\": 5}"] +Wish the web server handles route "/score/$" with handler { + return [$json "{\"score\": 5}"] } When the collected matches for [list /regionName/ has region /region/] are /regionMatches/ { - Wish the Web server handles route "/region/$" with handler [list Evaluator::tryRunInSerializedEnvironment { - set html "<ol>" + Wish the web server handles route "/regions/$" with handler [list Evaluator::tryRunInSerializedEnvironment { + set body "<ol>" foreach match $regionMatches { - append html "<li><strong>[dict get $match regionName]</strong>: [dict get $match region]</li>" + append body "<li><strong>[dict get $match regionName]</strong>: [dict get $match region]</li>" } - append html "</ol>" + append body "</ol>" + return [$html $body] } [Evaluator::serializeEnvironment]] } -Wish the Web server handles route "/redirect/$" with handler { - set response {raw "HTTP/1.1 302 Found\nLocation: https://folk.computer"} +Wish the web server handles route "/redirect/$" with handler { + return [dict create statusAndHeaders "HTTP/1.1 302 Found\nLocation: https://folk.computer"] } -Wish the Web server handles route {/pagee/(\d*)$} with handler { - if {[regexp -all {/pagee/(\d*)$} $path whole_match pageNumber]} { - set html "<h1>Hello Page Number $pageNumber</h1>" - } +Wish the web server handles route {/pagee/(\d*)$} with handler { + if {[regexp -all {/pagee/(\d*)$} $path whole_match pageNumber]} { + return [$html "<h1>Hello Page Number $pageNumber</h1>"] + } } |
