Emacs 23 supports server sockets and asynchronous server sockets. Elnode is an asychronous http server in elisp by NicFerrier.
The async approach has several benefits:
- emacs can use an external program (asynchronously of course) to do things
- Elnode uses cat as part of its webserver
- writing dynamic handlers is relatively easy
- it could serve as the foundation for many different services, Edit with Emacs (the Chrome browser edit tool) needs an Emacs http server
- the async approach doesn’t require threads to serve quite high loads
Below are two older approaches.
httpd.el was originally written by EricMarsden. See EmacsHttpd for the original.
JohnWiegley posted version 1.0 as:
- 2003-11-14 (1.0): This customized version of httpd.el is always current, plus whatever other modifications emacs-wiki.el or httpd-serve need.
httpd.el is an HTTP server embedded in the Emacs. It supports GET and HEAD requests for static and dynamic content. (supporting POST should be easy by stealing code from CommonGatewayInterface above).
Note the following if you use Emacs version 21.4 or lower: Since Emacs doesn’t support server sockets, you need to cheat a little and run it from a service such as tcpserver or inetd. You can get better performance by running a proxy server which forwards requests to a persistent emacs instance using gnuserv; see the commentary for details. Version 0.4, 2001-05-17 under GNU GPL.
phase.el is an HTTP server by AlexShinn under development, with cgi functionality and the ability to parse emacs lisp embedded in html documents.
The first one above does not work for emacs23, and the second one redirects to a blank page.
Here’s one that I am using now - http://nullprogram.com/blog/2009/05/17/
CommonGatewayInterface EricMarsden EmacsHttpd