http-server example: Resolve access to subfolder
This commit is contained in:
parent
834c78c044
commit
5282755f8e
1 changed files with 5 additions and 2 deletions
|
|
@ -34,7 +34,7 @@
|
||||||
(string/join (if attrs? (rest body) body))
|
(string/join (if attrs? (rest body) body))
|
||||||
(name tag))))
|
(name tag))))
|
||||||
body (cond
|
body (cond
|
||||||
(not (.exists f)) ""
|
(not (.exists f)) (str path " not exist")
|
||||||
(.isFile f) (slurp f)
|
(.isFile f) (slurp f)
|
||||||
(.isDirectory f) (format "<!DOCTYPE html>\n%s"
|
(.isDirectory f) (format "<!DOCTYPE html>\n%s"
|
||||||
(html :html
|
(html :html
|
||||||
|
|
@ -45,7 +45,10 @@
|
||||||
(html :tt
|
(html :tt
|
||||||
(apply html :pre
|
(apply html :pre
|
||||||
(for [i (.list f)]
|
(for [i (.list f)]
|
||||||
(html :div (html :a {:href (format "\"%s\"" i)} i)))))))))]
|
(html :div
|
||||||
|
(html :a
|
||||||
|
{:href (str (if (> (count path) 1) path) "/" i)} i)
|
||||||
|
))))))))]
|
||||||
(prn path)
|
(prn path)
|
||||||
(.write out (format "HTTP/1.1 %s OK\r\nContent-Length: %s\r\n\r\n%s"
|
(.write out (format "HTTP/1.1 %s OK\r\nContent-Length: %s\r\n\r\n%s"
|
||||||
status
|
status
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue