Hi,
I'm trying to set up a simple sql-based website using cl-who, cl-sql and hunchentoot. I've got the basic cl-sql and cl-who parts working, but I'm having a trouble serving the pages with hunchentoot.
The following works as expected:
(ql:quickload :hunchentoot) (use-package :hunchentoot)
(setf my-acceptor (start (make-instance 'hunchentoot:easy-acceptor :port 4242)))
(define-easy-handler (tyler :uri "/tyler") () (with-html-output (*standard-output*) (:ul (:li "hi there again"))))
After this, if I open localhost:4242/tyler in a browser I see my unordered list. However, with this:
(define-easy-handler (tyler :uri "/tyler") () (multiple-value-bind (records fields) (select [genus] [species] :from "specimens") (loop for rec in records do (loop for label in fields for val in rec do (with-html-output (*standard-output*) (:dt :class label (str label)) (:dd :class label (str val)))))))
When I browse to localhost:4242/tyler nothing appears in the browser, instead the html is printed in the REPL. If I evaluate just the (M-V-B ...) form without the enclosing (D-E-H ...) it outputs the html to the REPL as I expect.
I have been following the examples in the hunchentoot docs, but I'm stumped as to why this doesn't work. What have I missed?
Thanks,
Tyler
(define-easy-handler (tyler :uri "/tyler") () (multiple-value-bind (records fields) (select [genus] [species] :from "specimens") (loop for rec in records do (loop for label in fields for val in rec do (with-html-output (*standard-output*) (:dt :class label (str label)) (:dd :class label (str val)))))))
use with-html-output-to-string
-jens
I want to use hunchentoot to host a python CGI application. By searching, i found hunchentoot-cgi which exports a function called "create-cgi-dispatcher-and-handler".
(defun create-cgi-dispatcher-and-handler (uri-prefix base-path &optional content-type) ;... )
I have tried: (pushnew (hunchentoot-cgi::create-cgi-dispatcher-and-handler "/cgi-bin/" "/" ) *dispatch-table* :test #'equal)
When visiting http://127.0.0.1:8000/cgi-bin/nay.py, hunchentoot reports: Internal Server Error An error occured while processing your /cgi-bin/nay.py request. Error Message attempt to THROW to a tag that does not exist: HUNCHENTOOT-CGI::HANDLER-DONE Backtrace 0: (SB-DEBUG::MAP-BACKTRACE #<CLOSURE (LAMBDA # :IN BACKTRACE) {5AC7195D}> :START 0 :COUNT 536870911) 1: (BACKTRACE 536870911 #<SB-IMPL::STRING-OUTPUT-STREAM {5AC718F9}>) 2: (TRIVIAL-BACKTRACE:PRINT-BACKTRACE-TO-STREAM #<SB-IMPL::STRING-OUTPUT-STREAM {5AC718F9}>) 3: (HUNCHENTOOT::GET-BACKTRACE) 4: ((FLET #:LAMBDA769 :IN HUNCHENTOOT:HANDLE-REQUEST) #<SB-INT:SIMPLE-CONTROL-ERROR "attempt to THROW to a tag that does not exist: ~S" {5AC675A1}>) 5: (SIGNAL #<SB-INT:SIMPLE-CONTROL-ERROR "attempt to THROW to a tag that does not exist: ~S" {5AC675A1}>) 6: (ERROR SB-INT:SIMPLE-CONTROL-ERROR :FORMAT-CONTROL "attempt to THROW to a tag that does not exist: ~S" :FORMAT-ARGUMENTS (HUNCHENTOOT-CGI::HANDLER-DONE)) 7: (SB-KERNEL::UNSEEN-THROW-TAG-ERROR-HANDLER #<unavailable argument> #.(SB-SYS:INT-SAP #X293FF77C) #<SB-ALIEN-INTERNALS:ALIEN-VALUE :SAP #X293FF470 :TYPE (* (STRUCT SB-VM::OS-CONTEXT-T-STRUCT))> (144)) 8: (SB-KERNEL:INTERNAL-ERROR #.(SB-SYS:INT-SAP #X293FF470) #<unavailable argument>) 9: ("foreign function: call_into_lisp") 10: ("foreign function: funcall2") 11: ("foreign function: interrupt_internal_error") 12: ("foreign function: unblock_signals_in_context_and_maybe_warn") 13: ("no debug information for frame") 14: (HUNCHENTOOT-CGI::HANDLE-CGI-SCRIPT #P"/nay.py" #<unused argument>) 15: ((SB-PCL::FAST-METHOD HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)) #<unavailable argument> #<unavailable argument> #<HUNCHENTOOT:EASY-ACCEPTOR (host *, port 8000)> #<HUNCHENTOOT:REQUEST {5AB29089}>) 16: ((SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-REQUEST (T)) #<unavailable argument> #<unavailable argument> #<HUNCHENTOOT:REQUEST {5AB29089}>) 17: (HUNCHENTOOT::DO-WITH-ACCEPTOR-REQUEST-COUNT-INCREMENTED #<HUNCHENTOOT:EASY-ACCEPTOR (host *, port 8000)> #<CLOSURE (LAMBDA # :IN HUNCHENTOOT:PROCESS-CONNECTION) {5A97D965}>) 18: ((SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-CONNECTION (HUNCHENTOOT:ACCEPTOR T)) #<unavailable argument> #<unavailable argument> #<HUNCHENTOOT:EASY-ACCEPTOR (host *, port 8000)> #<USOCKET:STREAM-USOCKET {5BFC8901}>) 19: ((SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (HUNCHENTOOT:ACCEPTOR T)) #<unavailable argument> #S(SB-PCL::FAST-METHOD-CALL :FUNCTION #<FUNCTION #> :PV NIL :NEXT-METHOD-CALL NIL :ARG-INFO (2)) #<HUNCHENTOOT:EASY-ACCEPTOR (host *, port 8000)> #<USOCKET:STREAM-USOCKET {5BFC8901}>) 20: ((LAMBDA () :IN HUNCHENTOOT:CREATE-REQUEST-HANDLER-THREAD)) 21: ((LAMBDA () :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS)) 22: ((FLET #:WITHOUT-INTERRUPTS-BODY-227081 :IN SB-THREAD:MAKE-THREAD)) 23: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD:MAKE-THREAD)) 24: ((FLET #:WITHOUT-INTERRUPTS-BODY-88760 :IN SB-THREAD::CALL-WITH-MUTEX)) 25: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD:MAKE-THREAD) {293FFDF5}> #<SB-THREAD:MUTEX "thread result lock" owner: #<SB-THREAD:THREAD "hunchentoot-worker-127.0.0.1:19474" RUNNING {5BFD6639}>> #<SB-THREAD:THREAD "hunchentoot-worker-127.0.0.1:19474" RUNNING {5BFD6639}> T) 26: (SB-THREAD::INITIAL-THREAD-FUNCTION) 27: ("foreign function: call_into_lisp") 28: ("foreign function: funcall0") 29: ("foreign function: new_thread_trampoline") 30: ("foreign function: pthread_getprio") Hunchentoot 1.2.2 running on SBCL 1.0.54
Any suggestion is appreciated!
On Fri, Dec 23, 2011 at 12:31 AM, z_axis z_axis@163.com wrote:
I want to use hunchentoot to host a python CGI application. By searching, i found hunchentoot-cgi which exports a function called "create-cgi-dispatcher-and-handler".
[...]
Any suggestion is appreciated!
I think hunchentoot-cgi has not properly been ported to the current Hunchentoot version. You could try contacting the author to see whether he's got something in the cooking, or use an older (1.1) version of Hunchentoot.
Cheers, Hans
Your loop doesn't return anything, does it?
On Thu, Dec 22, 2011 at 11:51 PM, Tyler Smith tyler.smith@mail.mcgill.ca wrote:
Hi,
I'm trying to set up a simple sql-based website using cl-who, cl-sql and hunchentoot. I've got the basic cl-sql and cl-who parts working, but I'm having a trouble serving the pages with hunchentoot.
The following works as expected:
(ql:quickload :hunchentoot) (use-package :hunchentoot)
(setf my-acceptor (start (make-instance 'hunchentoot:easy-acceptor :port 4242)))
(define-easy-handler (tyler :uri "/tyler") () (with-html-output (*standard-output*) (:ul (:li "hi there again"))))
After this, if I open localhost:4242/tyler in a browser I see my unordered list. However, with this:
(define-easy-handler (tyler :uri "/tyler") () (multiple-value-bind (records fields) (select [genus] [species] :from "specimens") (loop for rec in records do (loop for label in fields for val in rec do (with-html-output (*standard-output*) (:dt :class label (str label)) (:dd :class label (str val)))))))
When I browse to localhost:4242/tyler nothing appears in the browser, instead the html is printed in the REPL. If I evaluate just the (M-V-B ...) form without the enclosing (D-E-H ...) it outputs the html to the REPL as I expect.
I have been following the examples in the hunchentoot docs, but I'm stumped as to why this doesn't work. What have I missed?
Thanks,
Tyler
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel