CGI Programming in Elisp?

戏子无情 提交于 2019-11-29 09:53:48

问题


Has anyone written any libraries for elisp to do CGI programming? I threw together a quick first script. However, I'm only a long-time emacs user and I've never really programmed it. When I saw that I could write scripts (--script) in emacs instead of bash, I thought that I would give it a shot.

#!/usr/bin/emacs --script

(princ "Content-type: text/html; charset=utf-8\n\n")

(progn (princ "<html>\n")
       (princ "<body>\n")
       (princ "<h1 style='text-align: center'>Elisp CGI Programming</h1>"))

(progn (princ "<table style='border:1px solid'>")
       (princ "<tr><th>One</th><th>Two</th></tr>")
       (princ "<tr><th>A</th><th>B</th></tr>")
       (princ "</table>")
       (princ "</body>")
       (princ "</html>")
)

回答1:


This might help you out, a simple cgi library for emacs

http://www.emacswiki.org/emacs/cgi.el




回答2:


I've not written any CGI scripts, but have used xmlgen to generate xml. It'd likely be easier than what you had up there - as it's easy to generate lists in Emacs and have them automatically converted to xml/html.

This code generates the same string:

(require 'xmlgen)
(princ  "Content-type: text/html; charset=utf-8\n\n")
(princ (xmlgen '(html (body (h1 :style "text-align: center" "Elisp CGI Programming")
                      (table :style "border: 1px solid"
                             (tr (th "One")
                                 (th "Two"))
                             (tr (th "A")
                                 (th "B")))))))



回答3:


One way to do it is, use the httpd server in Emacs HttpServer and send request to emacs using proxy.



来源:https://stackoverflow.com/questions/1532311/cgi-programming-in-elisp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!