Paste: tea server
Author: | frew |
Mode: | factor |
Date: | Sat, 30 Oct 2010 20:09:53 |
Plain Text |
USING:
http.client json.reader io.encodings.string io.encodings.utf8 accessors
furnace.actions html.forms http http.server kernel assocs sequences
http.server.dispatchers http.server.responses namespaces urls xml.syntax xml.writer ;
IN: friendly.tea
: _data "data" swap at ;
: _unpack http-get swap drop utf8 decode json> _data ;
: current-time "http://localhost:5000/current_tea" _unpack ;
: all-times "http://localhost:5000" _unpack ;
: nth-time all-times nth ;
: rand "http://localhost:5000/rand" _unpack ;
: name "name" swap at ;
: steep-time "steep_time" swap at ;
: preparation-time "preparation_time" swap at ;
: available-time "available_time" swap at ;
: page <XML <html>
<head>
<title> "tea" </title>
</head>
<body>
<p> <-> </p>
</body>
</html>
XML> xml>string ;
TUPLE: hello < dispatcher ;
: <hello-action>
<page-action>
[ current-time name page "text/html" <content> ] >>display ;
: <hello>
hello new-dispatcher
<hello-action> "" add-responder ;
: run-hello
<hello>
main-responder set-global
8080 httpd ;
MAIN: run-hello
New Annotation