Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 672 Bytes

clj-web-from-the-ground-up-1.md

File metadata and controls

35 lines (29 loc) · 672 Bytes

new app

$ lein new app clj-web

update dependencies on project.clj

  :dependencies [[org.clojure/clojure "1.11.1"]
                 [ring/ring-core "1.11.0"]
                 [ring/ring-jetty-adapter "1.11.0"]]

add basic handler to src\clj_web\core.clj

(defn handler [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body "Hello World"})

start on -main

(ns clj-web.core
  (:gen-class)
  (:require [ring.adapter.jetty :refer [run-jetty]]))

..

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (run-jetty handler {:port 3000}))

lein run & the app can be accessed at http://localhost:3000/