]> gitweb.factorcode.org Git - factor.git/commitdiff
webapps.calculator: using run-test-httpd word
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 5 Dec 2016 08:40:29 +0000 (09:40 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Mon, 5 Dec 2016 08:40:29 +0000 (09:40 +0100)
extra/webapps/calculator/calculator.factor

index cdfd6b988d71d095f3062ccf39616f7abd27f494..402143b947da5f3448ea946633c662b1c9968d96 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: furnace furnace.actions furnace.redirection
-http.server.dispatchers html.forms validators urls accessors
-math kernel io.directories fry ;
+USING: accessors furnace.actions furnace.alloy furnace.redirection
+html.forms http.server http.server.dispatchers math namespaces urls
+validators webapps.utils ;
 IN: webapps.calculator
 
 TUPLE: calculator < dispatcher ;
@@ -31,19 +31,14 @@ TUPLE: calculator < dispatcher ;
         <calculator-action> >>default ;
 
 ! Deployment example
-USING: db.sqlite furnace.alloy namespaces http.server ;
+: calculator-db ( -- db ) "calculator.db" <temp-sqlite-db> ;
 
-: calculator-db ( -- db ) "calculator.db" <sqlite-db> ;
+: <calculator-app> ( -- dispatcher )
+    <calculator> calculator-db <alloy> ;
 
-: run-calculator ( port -- )
-    '[
-        <calculator>
-            calculator-db <alloy>
-            main-responder set-global
-        _ httpd drop
-    ] with-resource-directory ;
+! Calculator runs at port 8081 and 8431
+: run-calculator ( -- )
+    <calculator-app> main-responder set-global
+    run-test-httpd ;
 
-: run-calculator-main ( -- )
-    8080 run-calculator ;
-
-MAIN: run-calculator-main
+MAIN: run-calculator