diff options
author | Pjotr Prins | 2023-08-28 12:17:07 +0200 |
---|---|---|
committer | Pjotr Prins | 2023-08-28 12:17:07 +0200 |
commit | 89801fbdb731ab64d49dd92fe5ad3ac2ee647e4d (patch) | |
tree | 8b79f41fdc3fa7acbd79f2859b21458d1ed3b18e /web/webserver.scm | |
parent | 2b11169a6757481dd33169bed1579620caad6fc5 (diff) | |
download | gn-guile-89801fbdb731ab64d49dd92fe5ad3ac2ee647e4d.tar.gz |
Serve image
Diffstat (limited to 'web/webserver.scm')
-rwxr-xr-x | web/webserver.scm | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/web/webserver.scm b/web/webserver.scm index 91ff6d6..d697735 100755 --- a/web/webserver.scm +++ b/web/webserver.scm @@ -18,6 +18,7 @@ ;; (ice-9 source) (srfi srfi-1) (srfi srfi-11) ; let-values + (srfi srfi-19) ; time (srfi srfi-26) (rnrs io ports) ; bytevector-all (web http) @@ -88,22 +89,15 @@ otherwise search for set/group data" (define (file-extension file-name) (last (string-split file-name #\.))) -(define* (render-static-image path #:key (extra-headers '())) - (list `((content-type - . ,(assoc-ref file-mime-types - (file-extension "CMOR.jpg"))) ; (last-modified . ,(time-utc->date modified)) - ) - (call-with-input-file "./static/images/CMOR.jpg" get-bytevector-all))) - -#! -(call-with-input-file "./static/images/CMOR.jpg" get-bytevector-all) -(list (append extra-headers - '((content-type . (application/octet-stream))) - (lambda (port) - (put-bytevector port - (call-with-input-file "./static/images/CMOR.jpg" get-bytevector-all) - ) -!# +(define* (render-static-image file-name #:key (extra-headers '())) + (let* ((stat (stat file-name #f)) + (modified (and stat + (make-time time-utc 0 (stat:mtime stat))))) + (list `((content-type . ,(assoc-ref file-mime-types + (file-extension file-name))) + (last-modified . ,(time-utc->date modified))) + + (call-with-input-file "./static/images/CMOR.jpg" get-bytevector-all)))) (define* (render-doc path page #:optional rec #:key (extra-headers '())) (list (append extra-headers |