 
 (defn header [title]
   [:head [:title title ]])
+
 (defn body [users]
   [:body 
    [:h2 "known users"]
    (users->table users) 
-   [:br]])
+   [:br]
+   [:p (str "Page accessed " (swap! page-count inc) " times") ]])
+
 (defn html-page [title users]
   [:html 
    (header title)

   :headers headers
   :body body })

(defn users-to-map [users-map] 
  (loop [my-users (get users-map "users")
         html {}]
    (if (empty? my-users)
      (let [ my-user (first my-users) ]
        (recur (rest my-users) (assoc html (keyword (first my-user))
                                      (second my-user)))))))


(defn handle-post-new [req] 
  (let [ json-data (slurp (:body req)) ]
    (json->atom (json/read-str json-data))
    (print-users)
    (http-reply 200 {"Content-Type" "text/html"} 
                (h/html (html-page "System users" users)))))



(require '[org.httpkit.server :as http] 
         '[clojure.data.json :as json]
         '[hiccup.core :as h])

(def port 8080)
(def users (atom {:tero "passu" :pasi "ppaswd" :harri "wdp"}))
(def page-count (atom 0))


(defn print-users []
  (doseq [ user  @users ]
    (println (str (first user) " " (second user)))))

(defn users->table [users]
  [:table 
