Hello,
I'm a user of tbnl and finally decided to make the switch to hunchentoot. When trying what's below, i get an empty page in the web browser.
Here is what i'm trying :
(defparameter *web-server* (start-server :port 3000))
(defmacro with-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue t) ,@body))
(defparameter *original-standard-output* *standard-output*)
(defmethod dispatch-request :around (dispatch-table) (pprint "coucou1" *original-standard-output*) (let ((result (call-next-method))) (pprint result *original-standard-output*) (pprint "coucou2" *original-standard-output*) result))
(defun bleh () (with-html (:html (:head (:title "easy demo")) (:body "That's bleh !"))))
(setq *dispatch-table* (list (create-prefix-dispatcher "/" #'bleh)))
Here is what i see on my standard ouput when i try to visit the web site at this address : http://localhost:3000/
"coucou1" "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>easy demo</title></head><body>That's bleh !</body></html>" "coucou2"
So it seems that everything goes well ... i'm at a loss wrt what i should do now to actually see the web page ... Thanks in advance for any pointer.
My config : lispworks 5.0, win32, firefox, standalone hunchentoot (no mod_lisp, no apache)
Sacha
Phlex wrote:
Hello,
I'm a user of tbnl and finally decided to make the switch to hunchentoot. When trying what's below, i get an empty page in the web browser.
Here is what i'm trying :
(defparameter *web-server* (start-server :port 3000))
(defmacro with-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue t) ,@body))
(defparameter *original-standard-output* *standard-output*)
(defmethod dispatch-request :around (dispatch-table) (pprint "coucou1" *original-standard-output*) (let ((result (call-next-method))) (pprint result *original-standard-output*) (pprint "coucou2" *original-standard-output*) result))
(defun bleh () (with-html (:html (:head (:title "easy demo")) (:body "That's bleh !"))))
(setq *dispatch-table* (list (create-prefix-dispatcher "/" #'bleh)))
Here is what i see on my standard ouput when i try to visit the web site at this address : http://localhost:3000/
"coucou1" "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>easy demo</title></head><body>That's bleh !</body></html>" "coucou2"
So it seems that everything goes well ... i'm at a loss wrt what i should do now to actually see the web page ... Thanks in advance for any pointer.
My config : lispworks 5.0, win32, firefox, standalone hunchentoot (no mod_lisp, no apache)
Try an easy-handler like this
(define-easy-handler (test :uri (prefixed "test"))() (with-html-output-to-string (out) (:html (:head (:title "Testpage")) (:body "Hello World))))
Jens
Try an easy-handler like this
(define-easy-handler (test :uri (prefixed "test"))() (with-html-output-to-string (out) (:html (:head (:title "Testpage")) (:body "Hello World"))))
--------------------------^ one double quote missing, sorry
Jens
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
On Wed, 07 Mar 2007 10:48:43 +0100, Phlex Phlex@telenet.be wrote:
I'm a user of tbnl and finally decided to make the switch to hunchentoot. When trying what's below, i get an empty page in the web browser.
Here is what i'm trying :
(defparameter *web-server* (start-server :port 3000))
(defmacro with-html (&body body) `(with-html-output-to-string (*standard-output* nil :prologue t) ,@body))
(defparameter *original-standard-output* *standard-output*)
(defmethod dispatch-request :around (dispatch-table) (pprint "coucou1" *original-standard-output*) (let ((result (call-next-method))) (pprint result *original-standard-output*) (pprint "coucou2" *original-standard-output*) result))
(defun bleh () (with-html (:html (:head (:title "easy demo")) (:body "That's bleh !"))))
(setq *dispatch-table* (list (create-prefix-dispatcher "/" #'bleh)))
Here is what i see on my standard ouput when i try to visit the web site at this address : http://localhost:3000/
"coucou1" "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>easy demo</title></head><body>That's bleh !</body></html>" "coucou2"
So it seems that everything goes well ... i'm at a loss wrt what i should do now to actually see the web page ... Thanks in advance for any pointer.
Your example works fine for me if entered in the order you showed above (assuming you're within a package where the Hunchentoot and CL-WHO symbols are accessible).
If you don't see anything in your browser, my /guess/ is that maybe you redefined BLEH. I'd recommend using
(setq *dispatch-table* (list (create-prefix-dispatcher "/" 'bleh)))
instead, so changes to BLEH are immediately picked up.
Let us know if that doesn't help.
Cheers, Edi.
Edi Weitz wrote:
Your example works fine for me if entered in the order you showed above (assuming you're within a package where the Hunchentoot and CL-WHO symbols are accessible).
If you don't see anything in your browser, my /guess/ is that maybe you redefined BLEH. I'd recommend using
(setq *dispatch-table* (list (create-prefix-dispatcher "/" 'bleh)))
instead, so changes to BLEH are immediately picked up.
Let us know if that doesn't help.
Cheers, Edi. _____
I've tried Mr Teich solution with no success.
Thanks for the pointer about using the symbol name of the function instead of the function pointer. I've been using an additional level of indirection with tbnl for months... and now i see this: very usefull =)
I've been trying all this in a fresh image (only asdf:load-op's and use-package's are left out of my example code) and still the web browser shows nothing but an empty page (page size = 0 byte)
Beside, the debug output shows that the bleh function was called and the result sent to hunchentoot.
I'll try re-installing all support libraries (which i thought i did yesterday) and see if that helps...
I'll keep you updated
Thanks for your time Sacha
On Wed, 07 Mar 2007 11:44:46 +0100, Phlex Phlex@telenet.be wrote:
That was the problem... I didn't update the trivial-gray-streams and flexi-streams libraries.
Hehe... :)
Sorry about this false alarm !
No problem.
On Wed, March 7, 2007 5:11 am, Edi Weitz said:
(setq *dispatch-table* (list (create-prefix-dispatcher "/" #'bleh)))
you redefined BLEH. I'd recommend using
(setq *dispatch-table* (list (create-prefix-dispatcher "/" 'bleh)))
instead, so changes to BLEH are immediately picked up.
I'd like to understand from a lisp standpoint why this works the way it does. What is it about the function operator #' that it only grabs the value of the symbol when first evaluated? Is there a 'hidden' closure operation?
Scribit Jonathon McKitrick dies 07/03/2007 hora 18:15:
I'd like to understand from a lisp standpoint why this works the way it does. What is it about the function operator #' that it only grabs the value of the symbol when first evaluated? Is there a 'hidden' closure operation?
No need for this. Each symbol has an associated reference to a function. The symbol-function operator just returns this reference. After calling it, changing the symbol's function to another one only makes that the function you just got a reference to is not referenced anymore by this symbol.
If you want a function that would change when the symbol is redefined, use the following instead of symbol-function:
(defun tracking-symbol-function (symbol) (lambda (&rest args) (apply (symbol-function symbol) args)))
Obviously there's an overhead when calling this one.
Quickly, Pierre