got the sandbox to start working.

This commit is contained in:
Danny Yoo 2013-04-05 14:13:55 -06:00
parent 1dfa615d5f
commit 54bc7c45ce

View File

@ -16,6 +16,8 @@
"../js-assembler/assemble.rkt" "../js-assembler/assemble.rkt"
(for-syntax racket/base)) (for-syntax racket/base))
(provide start-server)
(define-runtime-path htdocs (build-path "htdocs")) (define-runtime-path htdocs (build-path "htdocs"))
(define language (define language
@ -75,6 +77,7 @@
[else #f])) [else #f]))
;; Compile the program here... ;; Compile the program here...
(with-handlers ([exn:fail? (lambda (exn) (with-handlers ([exn:fail? (lambda (exn)
(printf "Error: ~s\n" (exn-message exn))
(write-json (hash 'type "error" (write-json (hash 'type "error"
'message (exn-message exn)) 'message (exn-message exn))
op))]) op))])
@ -119,10 +122,12 @@
(define (start-server #:port [port 8000]) (define (start-server #:port [port 8000]
#:listen-ip [listen-ip "127.0.0.1"])
(thread (lambda () (thread (lambda ()
(printf "starting web server on port ~s\n" port) (printf "starting web server on port ~s\n" port)
(serve/servlet start (serve/servlet start
#:listen-ip listen-ip
#:servlet-path "/compile" #:servlet-path "/compile"
#:extra-files-paths (list htdocs) #:extra-files-paths (list htdocs)
#:launch-browser? #f #:launch-browser? #f
@ -133,7 +138,7 @@
(require racket/cmdline) (require racket/cmdline)
(void (command-line (void (command-line
#:once-each #:once-each
[("-p" "--port") p "Port (default 8080)" [("-p" "--port") p "Port (default 8000)"
(current-port (string->number p))])) (current-port (string->number p))]))
(start-server #:port (current-port))) (start-server #:port (current-port)))