Browse files

rm 0

  • Loading branch information...
1 parent fdb89db commit e5122fc0e60445260f8bae2a1c36d3637dc2e67c Heow Goodman committed Nov 9, 2011
Showing with 0 additions and 32 deletions.
  1. +0 −32 src/example0.clj
View
32 src/example0.clj
@@ -1,32 +0,0 @@
-(ns example0
- (:use [ring.adapter.jetty :only [run-jetty]]
- [compojure.core :only [defroutes GET POST]]
- [ring.middleware.cookies :only [wrap-cookies]]
- [ring.middleware.params :only [wrap-params]]
- [ring.middleware.keyword-params :only [wrap-keyword-params]]))
-
-(defn main-page [cookies]
- (str "Hi there "
- (if (empty? (:value (cookies "name")))
- "<form method='post' action='/'> What's your name? <input type='text' name='name' /><input type='submit' /></form>"
- (:value (cookies "name")))))
-
-(defn process-form [params cookies]
- (let [name (if (not (empty? (:name params)))
- (:name params)
- (:value (cookies "name")))]
-
- ;; set cookie, return html
- {:cookies {"name" name}
- :body (str "<html><head><meta HTTP-EQUIV='REFRESH' content='5; url='/'\"</head><body>Thanks!</body></html>")}))
-
-(defroutes routes
- (POST "/" {params :params cookies :cookies} (process-form params cookies))
- (GET "/" {cookies :cookies} (main-page cookies)))
-
-(def app (-> #'routes wrap-cookies wrap-keyword-params wrap-params))
-
-(defn -main []
- (run-jetty app {:port (if (nil? (System/getenv "PORT"))
- 8000 ; localhost or heroku?
- (Integer/parseInt (System/getenv "PORT")))}) )

0 comments on commit e5122fc

Please sign in to comment.