/extra/webapps/ip/ip.factor

http://github.com/abeaumont/factor · Factor · 23 lines · 16 code · 5 blank · 2 comment · 0 complexity · 0a9c76cdbd1bf189f51a9fac4f4ffaec MD5 · raw file

  1. ! Copyright (C) 2008 Doug Coleman.
  2. ! See http://factorcode.org/license.txt for BSD license.
  3. USING: accessors furnace.actions http.server
  4. http.server.dispatchers html.forms io.sockets
  5. namespaces prettyprint kernel ;
  6. IN: webapps.ip
  7. TUPLE: ip-app < dispatcher ;
  8. : <display-ip-action> ( -- action )
  9. <page-action>
  10. [ remote-address get host>> "ip" set-value ] >>init
  11. { ip-app "ip" } >>template ;
  12. : <ip-app> ( -- dispatcher )
  13. ip-app new-dispatcher
  14. <display-ip-action> "" add-responder ;
  15. : run-ip-app ( -- )
  16. <ip-app> main-responder set-global
  17. 8080 httpd drop ;
  18. MAIN: run-ip-app