Providing access to a command line app trough HTTP with node.JS
I often create little bash/C/obscure other language/… programs that I like to share, However,these
programs are often not made to be hooked up to the Internet. So I use this script to create a
quick web interface for my program and put it up on some cheap server.
The basic script is this:
You can use url.parse(request.url) to get the parts of the URL. The pathname gives the path without
query string, splitting this on / will give you an array of parameters. The
NodeJS URL documentation gives an overview of the parts of the
request URL that you can easily retrieve.
Tough the snippet states it, I would like to stress that you should validate the input
strictly. If you don’t your server wont be yours for long…