fukamachi / woo

A fast non-blocking HTTP server on top of libev
http://ultra.wikia.com/wiki/Woo_(kaiju)
MIT License
1.27k stars 96 forks source link

How to load contents from a file? #105

Closed Corazone777 closed 1 year ago

Corazone777 commented 1 year ago

Not really an issue with the woo itself, rather a lack of understanding from my part.

I want to do something like this

(defparameter *file-contents* (read-html-file "index.html"))

(defvar *app*
  (lambda (env)
    '(200 (:content-type "text/plain") (*file-contents*))))

(defun start-server ()
  (woo:run
   *app*))

I searched online and was not able to find any answers.

fukamachi commented 1 year ago

A pathname is allowed as a response body like:

(defvar *app*
  (lambda (env)
    '(200 (:content-type "text/plain") #P"index.html")))

Lack's README will help you to get how to write an app.

https://github.com/fukamachi/lack

Corazone777 commented 1 year ago

Thanks you so much