{"id":811,"date":"2004-04-04T13:40:49","date_gmt":"2004-04-04T17:40:49","guid":{"rendered":"\/?p=811"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-30T04:00:00","slug":"modal_web_server","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2004\/04\/04\/modal_web_server\/","title":{"rendered":"Modal Web Server"},"content":{"rendered":"<p>\n<a href=\"http:\/\/radio.weblogs.com\/0102385\/2004\/04\/03.html#a568\">Chris Double<\/a> implemented a simple continuation-based Web framework in Scheme. Here&rsquo;s an <a href=\"http:\/\/www.double.co.nz\/scheme\/modal-web-server.html\">example<\/a>:\n<\/p>\n\n<blockquote cite=\"http:\/\/www.double.co.nz\/scheme\/modal-web-server.html\">\n<p>&lsquo;show-message&rsquo; is a function that displays an HTML page with a\nmessage and an &lsquo;Ok&rsquo; anchor. The &lsquo;Ok&rsquo; anchor goes to an URL as described\nabove:<\/p>\n\n<pre class=\"code\">\n(define (show-message msg)\n  (show\n   (lambda (url)\n     (sxml->html-string\n      `(html\n        (head (title ,msg))\n        (body\n         (p ,msg)\n         (p (a (@ (href ,url)) \"Ok\")))))))\n<\/pre>\n\n<p>We can use this by registering with the server a function that\ncalls it a couple of times:<\/p>\n\n<pre>\n(register-function\n (lambda ()\n   (show-message \"Hello\")\n   (show-message \"World\")))\n<\/pre>\n\n<p>Accessing the registered function displays the first &lsquo;Hello&rsquo;\npage. Clicking &lsquo;Ok&rsquo; will then resume the function and display the\nsecond &lsquo;World&rsquo; page. Clicking &lsquo;Ok&rsquo; on that page exits the function.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Chris Double implemented a simple continuation-based Web framework in Scheme. Here&rsquo;s an example: &lsquo;show-message&rsquo; is a function that displays an HTML page with a message and an &lsquo;Ok&rsquo; anchor. The &lsquo;Ok&rsquo; anchor goes to an URL as described above: (define (show-message msg) (show (lambda (url) (sxml->html-string `(html (head (title ,msg)) (body (p ,msg) (p (a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-811","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=811"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/811\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}