aboutsummaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
authorArun Isaac2019-08-27 12:19:37 +0530
committerArun Isaac2019-08-27 12:19:37 +0530
commit7e92f58be075e11d6c88eb2fec19413b2247ac9d (patch)
treebb84e432cb13332efab21d8a1bd9f1badc4c8f8d /ennu.el
parent45683deb00d8e5417dc08cc32af439832f173968 (diff)
downloadennum-7e92f58be075e11d6c88eb2fec19413b2247ac9d.tar.gz
ennum-7e92f58be075e11d6c88eb2fec19413b2247ac9d.tar.lz
ennum-7e92f58be075e11d6c88eb2fec19413b2247ac9d.zip
Implement test HTTP server.
* ennu.el (ennu-serve): New function.
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el15
1 files changed, 15 insertions, 0 deletions
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)