Paste: very, very, very basic webserver
Author: | ben_m |
Mode: | factor |
Date: | Fri, 19 Feb 2010 03:52:54 |
Plain Text |
USING: accessors io io.encodings.utf8 io.servers.connection multiline
threads ;
IN: simple-webserver
CONSTANT: port 8080
CONSTANT: host "localhost"
STRING: static-site
HTTP/1.1 200 OK
<html>
<head>
<title>Mojolicious, baby!</title>
</head>
<body>
<h1>Hi there</h1>
</body>
</html>
;
: handle-request ( -- )
static-site print ;
: <webserver> ( -- threaded-server )
utf8 <threaded-server>
"time-server" >>name
port >>insecure
[ handle-request ] >>handler ;
: start-webserver ( -- threaded-server )
<webserver> [ start-server ] in-thread ;
: stop-webserver ( threaded-server -- )
stop-server ;
New Annotation