1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors furnace.actions furnace.alloy furnace.redirection
4 html.forms http.server http.server.dispatchers math namespaces urls
5 validators webapps.utils ;
8 TUPLE: calculator < dispatcher ;
10 : <calculator-action> ( -- action )
14 { { "z" [ [ v-number ] v-optional ] } } validate-params
17 { calculator "calculator" } >>template
25 URL" $calculator" clone "x" value "y" value + "z" set-query-param
29 : <calculator> ( -- responder )
30 calculator new-dispatcher
31 <calculator-action> >>default ;
34 : calculator-db ( -- db ) "calculator.db" <temp-sqlite-db> ;
36 : <calculator-app> ( -- dispatcher )
37 <calculator> calculator-db <alloy> ;
39 ! Calculator runs at port 8081 and 8431
40 : run-calculator ( -- )
41 <calculator-app> main-responder set-global