start | find | index | login or register | edit
2009-11-04
by earl, 5457 days ago
In the spirit of 2006-05-07's minimal-but-not-totally-compliant HTTP server written in REBOL 2, here's the same thing written in REBOL 3:

r: to-binary ajoin [
"HTTP/1.0 503 Service Unavailable" crlf
"Content-type: text/plain" crlf
crlf
"server down for maintenance, we'll be back soon! "
"[503 service unavailable]" crlf
]

s: open tcp://:8080
s/awake: func [e] [if e/type = 'accept [close write first e/port r prin '.]]
wait s

Yay, one line down! Beware though, as this will happily idle at maximum CPU usage on Linux or OSX until bug #913 gets fixed.
powered by vanilla
echo earlZstrainYat|tr ZY @.
earl.strain.at • esa3 • online for 8662 days • c'est un vanilla site