UP | HOME

simple-httpd in emacs

I publish to a local directory first, then push that up to a server. I'm doing this at least until I hammer out some of the kinks in my setup (see, for example, the publishing notes). I was using a tool I wrote ages ago for this, but of course I'd rather keep it in emacs (as one does). To this end, I found out about simple-httpd, and added a few tweaks to my org.el file.

First, the code I wrote to enable it:

(use-package simple-httpd
  :ensure t
  :config
  (setq httpd-root "~/org/publish")
  (setq httpd-port 4000))

(let ((*httpd-server-running* nil))
  (defun httpd-toggle-server () (interactive)
         (if *httpd-server-running*
             (httpd-stop)
           (http-start))
         (setq *httpd-server-running* (not *httpd-server-running*))
         (not *httpd-server-running*)))

Then, I added support to my org-roam for this:

:bind (("C-c n l" . org-roam-buffer-toggle)
       ("C-c n f" . org-roam-node-find)
       ("C-c n g" . org-roam-graph)
       ("C-c n r" . org-roam-ref-add)
       ("C-c n s" . org-roam-db-sync)
       ("C-c n t" . org-roam-tag-add)
       ("C-c n i" . org-roam-node-insert)
       ("C-c n c" . org-roam-capture)
       ("C-c n j" . org-roam-dailies-capture-today)
       ("C-c n p" . metacircular-publish)
       ("C-c n u" . metacircular-upload)
       ("C-c n w" . httpd-toggle-server))

Author: kyle (kyle@imladris)

Date: 2025-04-27 Sun 14:18

Emacs 30.1 (Org mode 9.7.11)

Validate