Next: POST Echo, Previous: File Server, Up: Usage Examples [Contents][Index]
This example demonstrates access of URL-encoded parameters in a
GET
request. For example the following URL
http://localhost:9005/example?foo=bar&baz=qux will render as
the following HTML table.
foo | bar |
baz | qux |
;;; url-param-echo.el --- echo back url-paramed message using Emacs Web Server (ws-start '(((:GET . ".*") . (lambda (request) (with-slots (process headers) request (ws-response-header process 200 '("Content-type" . "text/html")) (process-send-string process (concat "URL Parameters:</br><table><tr>" (mapconcat (lambda (pair) (format "<th>%s</th><td>%s</td>" (car pair) (cdr pair))) (cl-remove-if-not (lambda (el) (stringp (car el))) headers) "</tr><tr>") "</tr></table>")))))) 9004)