1. Using hunchentoot as the website framework, its function is basically similar to Python's web. py
2. Use HTML-template
3. Database operations are not involved in this instance.
4. The main trouble is setting Chinese characters.
Here is the smallest available program that can correctly process the Chinese template file and the Chinese variable.
; Helper functions <br/> (require: ASDF) <br/> (defun loadlib (MOD) <br/> (ASDF: OOS 'asdf: Load-op mod )) </P> <p> (defun reload () <br/> (load "Web. lisp ") <br/> (defun restart-web () <br/> (progn <br/> (reload) <br/> (START-web ))) </P> <p>; Load Library <br/> (loadlib: HTML-template) <br/> (loadlib: hunchentoot) </P> <p>; set hunchentoot encoding <br/> (defvar * UTF-8 * (Flex: Make-external-format: UTF-8: EOL-style: lf) <br/> (setq hunchentoot: * hunchentoot-default-external-format ** UTF-8 *) <br/>; set the URL Handler Forwarding Table <br/> (push (hunchentoot: create-Prefix-dispatcher "/Hello" 'Hello) hunchentoot: * dispatch-table *) </P> <p>; Page controller function <br/> (defun Hello () <br/> (SETF (hunchentoot: Content-Type *) "text/html; charset = UTF-8") <br/> (with-output-to-string (Stream) <br/> (HTML-template: Fill-and-print-template <br/> # P "index. tmpl "<br/> (list: Name" lisp programmer ") <br/>: stream) <br/>; start the server <br/> (defun start-web (& optional (port 4444) <br/> (hunchentoot: Start (make-instance 'hunchentoot: Acceptor: port port) <br/>
Template index. tmpl
<! Doctype HTML public "-// IETF // dtd html // en"> <br/> <HTML> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> <br/> <title> test lisp Web </title> <br/> </pead> <br/> <body> <br/> <p> lisp web development instance </p> <br/> Hi, <! -- Tmpl_var name --> <br/> </body> <br/> </ptml> <br/>