fukamachi / ningle

Super micro framework for Common Lisp
http://8arrow.org/ningle/
273 stars 25 forks source link

Can't access POST parameters #2

Closed eudoxia0 closed 9 years ago

eudoxia0 commented 9 years ago

Using the following code:

(ql:quickload :ningle)

(defvar *app* (make-instance 'ningle:<app>))

(setf (ningle:route *app* "/")
      "<form action='/form' method='post'><input type='text' id='text'><input type='submit' value='Submit'></form>")

(setf (ningle:route *app* "/query" :method :GET)
      #'(lambda (params)
          (princ-to-string params)))

(setf (ningle:route *app* "/form" :method :POST)
      #'(lambda (params)
          (princ-to-string params)))

(clack:clackup *app*)

If you point your browser to http://localhost:5000/query?derp=herp, you'll see (derp herp). If you send a request with the form in the index page, you'll see nil. I'm not sure what I'm doing wrong here.

fukamachi commented 9 years ago

Because the input type='text' tag doesn't have a name attribute.

http://stackoverflow.com/questions/12543848/does-form-data-still-transfer-if-the-input-tag-has-no-name

eudoxia0 commented 9 years ago

Right! I thought it used the id attribute.

Sigh, I guess I'm getting too used to Django. Thanks!