! Copyright (C) 2008, 2009 Slava Pestov. ! See https://factorcode.org/license.txt for BSD license. USING: accessors furnace.actions furnace.alloy furnace.redirection html.forms http.server http.server.dispatchers kernel math namespaces urls validators webapps.utils ; IN: webapps.calculator TUPLE: calculator < dispatcher ; : ( -- action ) [ { { "z" [ [ v-number ] v-optional ] } } validate-params ] >>init { calculator "calculator" } >>template [ { { "x" [ v-number ] } { "y" [ v-number ] } } validate-params URL" $calculator" clone "x" value "y" value + "z" set-query-param ] >>submit ; : ( -- responder ) calculator new-dispatcher >>default ; ! Deployment example : calculator-db ( -- db ) "calculator.db" ; : ( -- dispatcher ) calculator-db ; ! Calculator runs at port 8081 and 8431 : run-calculator ( -- ) main-responder set-global run-test-httpd ; MAIN: run-calculator