newLips http server, access from within newLisp

Q&A's, tips, howto's
Locked
protozen
Posts: 36
Joined: Thu Aug 22, 2013 4:02 am

newLips http server, access from within newLisp

Post by protozen »

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?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: newLips http server, access from within newLisp

Post by Lutz »

you can start one or more new instances from a newLISP script:

Code: Select all

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

protozen
Posts: 36
Joined: Thu Aug 22, 2013 4:02 am

Re: newLips http server, access from within newLisp

Post by protozen »

Thanks Lutz. I was asking because I was hoping I could source link -x into a simple single executable .

protozen
Posts: 36
Joined: Thu Aug 22, 2013 4:02 am

Re: newLips http server, access from within newLisp

Post by protozen »

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.

Locked