Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.
The Factor web framework was recently rewritten. It's undergoing fairly rapid change so the notes here may get out of date. Hopefully they provide some tips on using it until the framework is documented.
Some other articles describing the framework are listed here. They may be slightly out of date to the version currently distributed with Factor. * The New HTTP Server Part 1 * The New HTTP Server Part 2
A very basic server for serving static files is listed below.
TUPLE: foo-website < dispatcher ;
: <foo-website> ( -- responder )
foo-website new-dispatcher
"resource:extra/websites/foo/www/" <static> >>default ;
: common-configuration ( -- )
<foo-website> main-responder set-global ;
: <foo-website-server> ( -- threaded-server )
<http-server>
8888 >>insecure ;
: start-website ( -- )
common-configuration
<foo-website-server> start-server ;
[ start-website ] in-thread
This starts a web server on port 8888. All requests go to a responder which serves the static files located at 'extra/websites/foo/www' relative to the Factor directory.
When a responder throws an error usually you get a generic server message saying there was an internal error. To get a stack trace you can set the server to a development mode using the following:
t development? set-global