This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: question about using the built-in web server
- From: Alex Mitchell <lexaay at gmail dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: "kawa at sourceware dot org" <kawa at sourceware dot org>
- Date: Mon, 14 May 2012 17:38:56 +0800
- Subject: Re: question about using the built-in web server
- References: <CBD1586A.39EB0%lexaay@gmail.com> <4FAB7AC5.3020107@bothner.com>
Hi Per,
Thanks for your help, as always.
> You could try:
> kawa --http-auto-handler / . -e '(gnu.kawa.servlet.KawaHttpHandler:startServer 8888)' mycode.scm
This doesn't seem to work, as mycode.scm is still not executed, but putting
(gnu.kawa.servlet.KawaHttpHandler:startServer 8888)
inside mycode.scm does work, or at least works to the extent that the
code in mycode.scm is run, and the server also responds to http
requests.
I did have one problem, however. I tried putting
(gnu.kawa.servlet.KawaHttpHandler:addAutoHandler "/" ".")
in mycode.scm, before starting the server, rather than using the
--http-auto-handler command-line option. The server starts and is able
to handle requests. However, when I created a file test.scm,
containing
#<p>Hello, <b>&(request-remote-host)</b>!</p>
and then loaded this file through the web browser, I get "unbound
location request-remote-host" on the server. I didn't have this
problem when using the http-auto-handler command-line option. I'm
assuming this has to do with which environment is accessible from
test.scm, and I suspect I may have similar problems when trying to
communicate between test.scm and mycode.scm.
> However, I'm guessing this may have threading issues. You probably want to run
> the server in a separate thread. Perhaps making use of HttpServer#setExecutor
> is needed, in which case we would need to make that calling from KawaHttpHandler.
I *think* I'm ok without this, as everything that I'm doing after
starting the webserver is in response to UI events, but I'll have to
do some testing to know for sure.
thanks,
Alex