]> code.delx.au - gnu-emacs-elpa/blob - packages/web-server/examples/001-hello-world-utf8.el
1108cfbd1a793714d5dfbc104b9978f84ed1d488
[gnu-emacs-elpa] / packages / web-server / examples / 001-hello-world-utf8.el
1 ;;; hello-world-utf8.el --- utf8 hello world server using Emacs Web Server
2 (ws-start
3 (lambda (request)
4 (with-slots (process headers) request
5 (let ((hellos '("こんにちは"
6 "안녕하세요"
7 "góðan dag"
8 "Grüßgott"
9 "hyvää päivää"
10 "yá'át'ééh"
11 "Γεια σας"
12 "Вiтаю"
13 "გამარჯობა"
14 "नमस्ते"
15 "你好")))
16 (ws-response-header process 200
17 '("Content-type" . "text/plain; charset=utf-8"))
18 (process-send-string process
19 (concat (nth (random (length hellos)) hellos) " world")))))
20 9001)