newLISP Fan Club

Forum => newLISP in the real world => Topic started by: protozen on February 18, 2015, 11:48:43 AM

Title: newLips http server, access from within newLisp
Post by: protozen on February 18, 2015, 11:48:43 AM
Are there any plans to offer an api to access the development server, with an api from newLisp instead of the command line? I'm looking at creating a few small packaged servers that I would like to have configured and executed from newLips. Having some soft of API for the built in HTTP processor would be nice. Has anyone done this before?
Title: Re: newLips http server, access from within newLisp
Post by: Lutz on February 18, 2015, 12:13:06 PM
you can start one or more new instances from a newLISP script:



newLISP v.10.6.2 64-bit on OSX IPv4/6 UTF-8 libffi, options: newlisp -h

> (process "/usr/bin/newlisp -http -d12345 -w/Users/lutz/test/")
9965
> (get-url "http://localhost:12345")
"<html>n<head>n<title>Index</title>n<h1>Hello World</h1>n</body>n</html>n"
>


the index.html is in the /Users/lutz/test/ working directory. Instead of port 12345 choose 80 for the HTTP default port, but you would need administrator permissions for ports < 1024 on Unix like platforms.



PS: see also the map-reduce example for net-eval servers instead of http servers:

http://www.newlisp.org/syntax.cgi?code/mapreduce.txt
Title: Re: newLips http server, access from within newLisp
Post by: protozen on February 18, 2015, 02:03:01 PM
Thanks Lutz. I was asking because I was hoping I could source link -x into a simple single executable .
Title: Re: newLips http server, access from within newLisp
Post by: protozen on February 19, 2015, 12:39:23 PM
I think I misunderstood in how net-eval can be used, as in the map reduce examples. It's not what I had in mind, but I think I get can what I wanted using this.