Last active
December 21, 2015 12:49
-
-
Save wynemo/6308077 to your computer and use it in GitHub Desktop.
wisp hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns tt.circle) | |
| (def PI (.-PI Math)) | |
| (defn area [r] (* PI r r)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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