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