PORT environment variable; maybe non-blocking
Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
parent
b174194068
commit
f7ebc53e96
14
meme.scm
14
meme.scm
|
@ -23,9 +23,12 @@
|
|||
#:use-module (web uri)
|
||||
#:use-module (web request)
|
||||
#:use-module (web http)
|
||||
#:use-module (ice-9 suspendable-ports)
|
||||
#:use-module (ice-9 textual-ports)
|
||||
#:use-module (ice-9 binary-ports))
|
||||
|
||||
(install-suspendable-ports!)
|
||||
|
||||
(define (handler request request-body)
|
||||
(let ((uri (request-uri request))
|
||||
(path (uri-path (request-uri request)))
|
||||
|
@ -84,6 +87,11 @@
|
|||
(meme-page path))
|
||||
(else (error-page 404)))))
|
||||
|
||||
|
||||
(run-server handler 'http '(#:port 8003
|
||||
#:addr 0))
|
||||
(define sock (socket PF_INET SOCK_STREAM 0))
|
||||
(let ((port (if (getenv "PORT")
|
||||
(string->number (getenv "PORT"))
|
||||
8003)))
|
||||
(bind sock AF_INET INADDR_ANY port)
|
||||
(fcntl sock F_SETFL (logior O_NONBLOCK
|
||||
(fcntl sock F_GETFL)))
|
||||
(run-server handler 'http `(#:socket ,sock)))
|
||||
|
|
Loading…
Reference in New Issue