NonGNU ELPA - simple-httpd

simple-httpd Atom Feed

Description
Pure Elisp HTTP server
Latest
simple-httpd-1.6.tar (.sig), 2026-May-19, 70.0 KiB
Maintainer
Philip Kaludercic <philipk@posteo.net>, Daniel Mendler <mail@daniel-mendler.de>
Website
https://github.com/skeeto/emacs-http-server
Browse ELPA's repository
CGit or Gitweb
All Dependencies
compat (.tar)
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

GNU Emacs NonGNU ELPA NonGNU-devel ELPA MELPA MELPA Stable

A simple Emacs web server.

This used to be httpd.el but there are already several of these out there already of varying usefulness. The server can serve files, directory listings and custom servlets. Client requests are sanitized, but the server is vulnerable to denial of service attacks, so it should only be used for local development or automation. We make no guarantees regarding security.

This package is available on MELPA and ELPA.

1. Usage

Once loaded, there are only two interactive functions to worry about: httpd-start and httpd-stop. By default, files are served from httpd-root on port httpd-port. To disable, set httpd-serve-files to nil. Directory listings are enabled by default but can be disabled by setting httpd-listings to nil.

(require 'simple-httpd)
(setq httpd-root "/var/www")
(httpd-start)

2. Servlets

Servlets can be defined with httpd-servlet. They are enabled by default but can be disabled by setting httpd-servlets to nil. This one creates at servlet at /hello-world that says hello.

(httpd-servlet hello-world text/plain (path)
  (insert "hello, " (file-name-nondirectory path)))

Another example at /greeting/<name> with optional parameter ?greeting=<greeting>.

(httpd-servlet* greeting/:name text/plain ((greeting "hi" greeting-p))
  (insert (format "%s, %s (provided: %s)" greeting name greeting-p)))

See the comment header in simple-httpd.el for full details.

3. Unit tests

The unit tests can be run with make test. The tests do some mocking to avoid using network code during testing.

4. Related packages

Packages built on simple-httpd:

Old versions

simple-httpd-1.5.1.tar.lz2026-Apr-2911.8 KiB

News

Version 1.6 (2026-05-19)

  • Depend on Compat, update for new Emacs versions.
  • httpd-servlet, httpd-servlet*, httpd-file-servlet, httpd-with-buffer: Alternative name for defservlet, defservlet*, httpd-def-file-servlet and with-httpd-buffer respectively.
  • httpd-log-buffer: New customizable variable for the log buffer. Optimize httpd-log if the log buffer is disabled.
  • httpd-html, httpd-error: Numeric and textual status code are passed as arguments to format. Add default error page.
  • Store server and client processes and shutdown all processes in httpd-stop.
  • Parse body as arguments only for mime type application/x-www-form-urlencoded.
  • Reduce creation of temporary buffers and improve performance.
  • Improve parser robustness with additional checks.
  • Improve asynchronous request handling, maintaining a queue of requests.

Version 1.5.1: improvements

  • Add httpd-running-p
  • Properly handle "Connection: close" and HTTP/1.0

Version 1.5.0: improvements

  • Drastically improved performance for large requests
  • More HTTP status codes

Version 1.4.6: fixes

  • Added httpd-serve-directory
  • Fix some encoding issues

Version 1.4.5: fixes

  • Update to cl-lib from cl

Version 1.4.4: features

  • Common Lisp &key-like defservlet* argument support
  • Fix up some defservlet* usage warnings.

Version 1.4.3: features

  • Add httpd-discard-buffer
  • Add httpd-def-file-servlet
  • Be more careful about not sending extra headers

Version 1.4.2: features, fixes

  • defservlet* macro

Version 1.4.1: small bug fixes, one feature

  • All mime-type parameters now accept string designators
  • Documentation update

Version 1.4.0: features, API change, and fixes

  • Removed httpd-send-buffer; httpd-send-header now does this implicitly
  • httpd-send-header now accepts keywords instead
  • Fix httpd-clean-path in Windows
  • Fix a content-length bug
  • defservlet fontification

Version 1.3.1: features and fixes

  • Set standard-output in with-httpd-buffer

Version 1.3.0: security fix

  • Fix path expansion security issue
  • Fix coding system (don't default)

Version 1.2.4: fixes

  • Handle large POSTs
  • Fix date strings