Skip to content

Commit d12585e

Browse files
committed
Add image and text file example (Thanks @pnathan).
Html goodness with cl-who. Add package.lisp and refactor example.asd.
1 parent 95d71d6 commit d12585e

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

example.asd

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
(in-package :asdf)
2-
3-
(defsystem :example
4-
:name "example"
5-
:description "Example cl-heroku application"
6-
:depends-on (:hunchentoot)
7-
:components
8-
((:static-file "example.asd")
9-
(:module :src
10-
:serial t
11-
:components
12-
((:file "hello-world"))
13-
)))
1+
(asdf:defsystem #:example
2+
:serial t
3+
:description "Example cl-heroku application"
4+
:depends-on (#:hunchentoot
5+
#:cl-who)
6+
:components ((:file "package")
7+
(:module :src
8+
:serial t
9+
:components ((:file "hello-world")))))
1410

package.lisp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
;;;; package.lisp
2+
3+
(defpackage #:example
4+
(:use #:cl))

public/hello.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hi. I'm a text file being served by Hunchentoot.

src/hello-world.lisp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
(in-package :hunchentoot)
1+
(in-package :example)
22

3-
(hunchentoot:define-easy-handler (hello-sbcl :uri "/") (name)
4-
(setf (hunchentoot:content-type*) "text/plain")
5-
(format nil "Hey~@[ ~A~]! ~A ~A, Hunchentoot ~A" name (lisp-implementation-type) (lisp-implementation-version) hunchentoot::*hunchentoot-version*))
3+
(push (hunchentoot:create-folder-dispatcher-and-handler "/static/" "/app/public/")
4+
hunchentoot:*dispatch-table*)
5+
6+
(hunchentoot:define-easy-handler (hello-sbcl :uri "/") ()
7+
(cl-who:with-html-output-to-string (s)
8+
(:html
9+
(:head
10+
(:title "Heroku CL Example App"))
11+
(:body
12+
(:h1 "Heroku CL Example App")
13+
(:h3 "Using")
14+
(:ul
15+
(:li (format s "~A ~A" (lisp-implementation-type) (lisp-implementation-version)))
16+
(:li (format s "Hunchentoot ~A" hunchentoot::*hunchentoot-version*))
17+
(:li (format s "CL-WHO")))
18+
(:div
19+
(:a :href "static/lisp-glossy.jpg" (:img :src "static/lisp-glossy.jpg" :width 100)))
20+
(:div
21+
(:a :href "static/hello.txt" "hello"))))))

0 commit comments

Comments
 (0)