Notes for using LISP to write website programs

Source: Internet
Author: User

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/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.