blob: dc9dc434ca2c54ef3e19aeb68e41bd43c6bd6726 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
(ns repl
(:require [core :refer [-main] :rename {-main build}]
[ring.adapter.jetty :as jetty]
[ring.middleware.file :as file]
[ring.middleware.content-type :as content-type]
[ring.util.response :as response]))
(defonce server (atom nil))
(defn app [request]
(or ((file/wrap-file identity "target/html") request)
(response/not-found "Not Found")))
(def handler
(-> app
content-type/wrap-content-type))
(defn start []
(when-not @server
(reset! server (jetty/run-jetty handler {:port 8080 :join? false}))
(println "Server started on http://localhost:8080")))
(defn stop []
(when @server
(.stop @server)
(reset! server nil)
(println "Server stopped")))
(defn restart []
(stop)
(start))
(defn serve []
(start))
(comment
(restart)
(build))
|