Is there a Guile equivalent of Python's -m http.server command?

GNU’s docs only show how to prepare a simple hello world response and the closest thing is the code use in the Haunt static site generator simple web server.

Maybe I should just extract that snippet into a function and evaluate it? Or is there a simpler way?

Hoot has a simple one derived from Haunt, and Andy Wingo said I should submit something similar to Guile so we can have an equivalent to http.server in Guile itself.

Bash one-liner to run it:

guile -c '((@ (hoot web-server) serve))'
4 Likes

Thanks!

(I should check the forum more often)

sorry for necro-posting. i am trying this only now.

i create a new Guix shell with Guile and run:

guile -c '((@ (hoot web-server) serve))'

i get back this:

guile -c '((@ (hoot web-server) serve))'
Backtrace:
In ice-9/boot-9.scm:
  1752:10  8 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
           7 (apply-smob/0 #<thunk 7f4640513300>)
In ice-9/boot-9.scm:
    724:2  6 (call-with-prompt ("prompt") #<procedure 7f4640520340 …> …)
In ice-9/eval.scm:
    619:8  5 (_ #(#(#<directory (guile-user) 7f4640516c80>)))
In ice-9/command-line.scm:
   185:19  4 (_ #<input: string 7f4640510850>)
In unknown file:
           3 (eval ((@ (hoot web-server) serve)) #<directory (guile-…>)
In ice-9/eval.scm:
   182:19  2 (proc #f)
   142:16  1 (compile-top-call #f (5 (hoot web-server) serve . #t) ())
In unknown file:
           0 (%resolve-variable (5 (hoot web-server) serve . #t) #f)

ERROR: In procedure %resolve-variable:
In procedure module-variable: Wrong type argument in position 1 (expecting module): #f

from reading the code it does not seem i have to install other packages for it. so, given i’m a noob with Guile, i can’t figure out what’s missing exactly.

I just attempted to reproduce with the following and it is working:

➜ guix shell guile-next guile-hoot
➜ guile -c '((@ (hoot web-server) serve))'
Serving directory: /home/trev
Listening on: 0.0.0.0:8088
1 Like

thank you, so i am missing guile-hoot after all!

1 Like