Skip to content

Instantly share code, notes, and snippets.

@wynemo
Last active December 21, 2015 12:49
Show Gist options
  • Select an option

  • Save wynemo/6308077 to your computer and use it in GitHub Desktop.

Select an option

Save wynemo/6308077 to your computer and use it in GitHub Desktop.
wisp hello world
(ns tt.circle)
(def PI (.-PI Math))
(defn area [r] (* PI r r))
(ns tt.nodeimport
(:require [tt.circle :as circle]))
(def http (require "http"))
(def url (require "url"))
(def server
(.createServer http
(fn [request response]
(.writeHead response 200 {"Content-Type" "text/plain"})
(def url_parts
(.parse url
(.-url request)
true))
(def query (.-query url_parts))
(.end response
(+ "area is "
(.area circle
(.-r query)))))))
(.listen server 8000)
(.log console "Server running at http://127.0.0.1:8000/")
; wget http://127.0.0.1:8000/?r=5
(def http (require "http"))
(def server
(.createServer http
(fn [request response]
(.writeHead response {"Content-Type" "text/plain"})
(.end response "hello world\n"))))
(.listen server 8000)
(.log console "Server running at http://127.0.0.1:8000/")
(ns tt.importmodule
(:require [tt.circle :as circle]))
(.log console
(+
"The area of a circle of radius 4 is "
(.area circle 4)))
; wisp importmodule.wisp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment