newLips http server, access from within newLisp

Q&A's, tips, howto's

newLips http server, access from within newLisp

Postby protozen » Wed Feb 18, 2015 7:48 pm

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?
protozen
 
Posts: 33
Joined: Thu Aug 22, 2013 4:02 am

Re: newLips http server, access from within newLisp

Postby Lutz » Wed Feb 18, 2015 8:13 pm

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
Lutz
 
Posts: 5276
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: newLips http server, access from within newLisp

Postby protozen » Wed Feb 18, 2015 10:03 pm

Thanks Lutz. I was asking because I was hoping I could source link -x into a simple single executable .
protozen
 
Posts: 33
Joined: Thu Aug 22, 2013 4:02 am

Re: newLips http server, access from within newLisp

Postby protozen » Thu Feb 19, 2015 8:39 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.
protozen
 
Posts: 33
Joined: Thu Aug 22, 2013 4:02 am


Return to newLISP in the real world

Who is online

Users browsing this forum: joejoe and 2 guests