mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 10:31:34 -08:00
48 lines
1.5 KiB
Common Lisp
48 lines
1.5 KiB
Common Lisp
;;; This starts a local web-server in order to preview/download the taken
|
|
;;; pictures on your desktop computer. Make sure you are in the same WiFi,
|
|
;;; and open:
|
|
;;;
|
|
;;; http://192.168.1.x:1701/
|
|
|
|
(in-package :camera)
|
|
|
|
(defvar *web-server* nil)
|
|
(defvar *image-path* nil)
|
|
|
|
(defvar *index.html*
|
|
"<!doctype html>
|
|
<html>
|
|
<head>
|
|
<style type=\"text/css\">
|
|
img { width: 100px; border-width: 10px; border-style: solid; border-color: white }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
~A
|
|
</body>
|
|
</html>")
|
|
|
|
(defvar *img.htm* "<a href=~S><img src=~S /></a>")
|
|
|
|
(defun ini (image-path)
|
|
(setf *web-server* (make-s-http-server))
|
|
(start-server *web-server*)
|
|
(register-context-handler *web-server* "/" 'static-resource-handler
|
|
:arguments (list image-path)))
|
|
|
|
(defun create-index.html (image-path) ; called from QML
|
|
"Creates 'index.html' for local web-server."
|
|
(unless *image-path*
|
|
(ini image-path))
|
|
(setf *image-path* image-path)
|
|
(with-open-file (s (merge-pathnames "index.html" image-path)
|
|
:direction :output :if-exists :supersede)
|
|
(format s *index.html*
|
|
(x:join (mapcar (lambda (file)
|
|
(let ((name (x:cc (pathname-name file) ".jpg")))
|
|
(format nil *img.htm* name name)))
|
|
(sort (directory (merge-pathnames "*_0*.jpg" image-path))
|
|
'string< :key 'pathname-name))
|
|
#\Newline)))
|
|
(values)) ; no return value to QML
|
|
|