Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Flan

A easy HTTP server for learning clojure

Get started

  • Install clojure

  • Create a empty directory and enter on it.

mkdir my-first-webapp
cd my-first-webapp
  • Create a deps.edn file and a src dir for sources
touch deps.edn
mkdir src
  • Copy and paste this into deps.edn
{:deps    {br.com.souenzzo/flang {:git/url "https://github.com/souenzzo/flan"
                                  :sha     "c387d06e36d9f03e0cf12c4fcf5814f7300a00c0"}}
 :aliases {:dev {:main-opts ["-m" "br.com.souenzzo.flan" "--dev" "my-first-webapp"]}}} 
  • Run it!
clj -A:dev
  • It will start at localhost:8080. Connect your browser into it and flow the instructions!

Simple examples

  • A simple and incomplete example of "Todo APP"
(defonce todos (atom #{}))

(defn -get
  [req]
  [:html
   [:head]
   [:body
    [:form
     {:method "POST"}
     [:input {:name "text"}]
     [:input {:type "submit"}]]
    [:ul
     (for [todo @todos]
       [:li todo])]]])

(defn -post
  [{:keys [params headers]}]
  (swap! todos conj (:text params))
  {:headers {"Location" (get headers "referer" "/")}
   :status  301})

About

A easy Web server for learning clojure

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages