Next: Hello World UTF8, Previous: Usage Examples, Up: Usage Examples [Contents][Index]
The simplest possible “hello world” example. The handler consists
of a single (matcher . handler) pair. The function matcher matches
every incoming HTTP request. The handler responds by setting
the content type to text/plain
, and then sending the string
“hello world”. When the handler exits the network connection of the
request is closed.
;;; hello-world.el --- simple hello world server using Emacs Web Server (ws-start (lambda (request) (with-slots (process headers) request (ws-response-header process 200 '("Content-type" . "text/plain")) (process-send-string process "hello world"))) 9000)