Created
June 30, 2014 20:19
-
-
Save pabzdzdzwiagief/b42080d2639988ee5c11 to your computer and use it in GitHub Desktop.
A simple static website server written in Clojure using ring, compojure and jetty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| web: lein run $PORT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defproject static "1.0.0" | |
| :dependencies [[org.clojure/clojure "1.6.0"] | |
| [ring "1.3.0"] | |
| [compojure "1.1.8"]] | |
| :source-paths ["src" "src/main/clojure"] | |
| :resource-paths ["src/main/resources"] | |
| :uberjar-name "static.jar" | |
| :min-lein-version "2.0.0" | |
| :main static.web | |
| :aot [static.web]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns static.web | |
| "Simple static file server using ring, compojure and jetty" | |
| (:require [ring.util.response :refer [resource-response]] | |
| [ring.adapter.jetty :refer [run-jetty]] | |
| [compojure.core :refer [defroutes GET]] | |
| [compojure.route :refer [resources]])) | |
| (defroutes app | |
| (GET "/" [] (resource-response "index.html" {:root "public"})) | |
| (resources "/")) | |
| (defn -main | |
| [port] | |
| (run-jetty app {:port (Integer/valueOf port) :join? false})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment