Okay .. this works for me - (setq *Port (port 3000))
(de process (Input) (if Input Input "Empty")) (loop (setq *Sock (listen *Port)) (unless (fork) (close *Port) (let Body (pipe (in *Sock (when (= "POST" (read)) (when (from "Content-Length: ") (let Len (read) (line) # read the newline after content length (while (line)) # Skip rest of header (echo Len) )))) (till NIL T)) (let Output (process Body) (out *Sock (prinl "HTTP/1.1 200 OK^M") (prinl "Content-Length: " (length Output) "^M^J^M") (prinl Output))) (bye) )) (close *Sock) ) Regards, Kashyap On Sat, May 18, 2019 at 3:43 PM C K Kashyap <ckkash...@gmail.com> wrote: > Super! ... almost what I was looking for .... I mean one minor fix is that > I have to call a (line) after (read) to read up the newline after the > content length. > Also, I need to figure out how to capture the body .... do I do a pipe? > Regards, > Kashyap > > On Sat, May 18, 2019 at 11:53 AM Alexander Burger <a...@software-lab.de> > wrote: > >> On Sat, May 18, 2019 at 08:11:20PM +0200, Alexander Burger wrote: >> > You can easily write a stand-alone server without any library: >> > ... >> >> Hmm, this was too short. I haven't tested, but at least we should respond >> something. Perhaps this is a better starting point: >> >> (setq *Port (port 8080)) >> >> (loop >> (setq *Sock (listen *Port)) >> (unless (fork) >> (close *Port) >> (in *Sock >> (when (from "Content-Length: ") >> (let Len (read) >> (while (line)) # Skip rest of header >> (out NIL (echo Len)) ) ) ) >> (out *Sock >> (prinl "HTTP/1.1 200 OK^M") >> (prinl "Content-Length: 0^M^J^M") >> (prinl "^M") >> (prinl "^M") ) >> (bye) ) >> (close *Sock) ) >> >> Just for experimentation ... ;) >> >> ☺/ A!ex >> >> -- >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >> >