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