From 7e92f58be075e11d6c88eb2fec19413b2247ac9d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 27 Aug 2019 12:19:37 +0530 Subject: Implement test HTTP server. * ennu.el (ennu-serve): New function. --- ennu.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ennu.el b/ennu.el index 01cabb7..c24739e 100644 --- a/ennu.el +++ b/ennu.el @@ -7,6 +7,7 @@ (require 'cl) (require 'map) (require 'memoize) +(require 'simple-httpd) (defvar ennu-version "0.1.0" "Ennu version string") @@ -444,4 +445,18 @@ as keys. Keys are compared using `equal'." (delete-directory output t) (rename-file temporary-directory output t)))))) +;;; Server +;;; +;;; Test HTTP server to serve the blog locally + +(defun ennu-serve () + (interactive) + (setq httpd-root (expand-file-name (ennu-setting :output-directory) + (ennu-setting :working-directory))) + (defun httpd/ (proc uri-path query request) + (pcase (httpd-status (httpd-gen-path uri-path)) + (200 (httpd-serve-root proc httpd-root uri-path request)) + (_ (httpd-serve-root proc httpd-root (concat uri-path ".html") request)))) + (httpd-start)) + (provide 'ennu) -- cgit v1.2.3