             in (new BufferedReader (new InputStreamReader (.getInputStream socket)))]
         (let [lines (consume-buffer in)]
           (if (not (empty? lines))
-            (pp/pprint (parse-request lines)))
+            (let [request (parse-request lines)]
+              (pp/pprint request)
+              (let [[_ & relative] ((request :request-line) :uri)]
+                (if (and (not (empty? relative)) (fs/exists? (str/join relative)))
+                  (.println out (generate-response :200 (slurp(str/join relative))))
+                  (.println out (generate-response :404 nil)))))
+            (.println out (generate-response :404 nil)))
+          (.flush out)
+          (.close out)
+          (.close in)
+          (.close socket)
           (recur server))))))
 
 

                             (assoc memo (keyword k) (str/trim v))))
                      (sorted-map) headers)}))

(defn run-server [port]
  (println (format "server accepting request on %s" port))
  (loop [server (new ServerSocket port)]

(ns inf4375-simple-server.core
  (:gen-class)
  (:import (java.io InputStreamReader PrintWriter BufferedReader ByteArrayOutputStream )
           (java.net ServerSocket))
  (:require [clojure.string :as str]
            [clojure.pprint :as pp]
            [me.raynes.fs   :as fs]))

(defn consume-buffer [input]
  (loop  [lines '()]
    (if (.ready input)
      (recur(concat lines (list (.readLine input))))
      (remove (fn [l] (empty? l))lines))))

(defn parse-request [lines]
  (let [[request-line & headers] lines
