August, 2017
28
Ever since alwaysdata’s inception – more than 10 years ago! – it’s been possible to run web applications using three major languages: PHP, Python, and Ruby. While PHP has been a heavyweight for a long time, Python and Ruby were, back then, the new kids on the block in the web world, and we were among the very first hosts to run applications written in those languages.
Today, PHP is still a heavyweight, Python and Ruby have matured, and the new kids on the block have multiplied: Node.js, Go, Lua, Elixir, Haskell, Clojure, etc. Even though interpreters and compilers were already installed on our servers and it was possible to use them, for example, in SSH, it was not possible to run applications that had been developed in those languages on the web… up until now!
A new type of website is cropping up: User program. When making a website of this type, you have to specify a command to be executed and that will start an HTTP server. This program can be written in the language of your choice, interpreted, or compiled: if the command works correctly (you can try it out it in SSH), your application will be reachable.
An example with Node.js
Let’s use the example of a Hello World being implemented in Node.js. Create a ~/www/app.js file that contains:
1 2 3 4 5 6 7 8 | var http = require('http'); var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("Hello World\n"); }); server.listen(8100, '127.3.151.58'); |
The program will listen in on the IP 127.1.251.59 and port 8100: these are not random values, you will have to use the ones being specified when you create your website, in alwaysdata’s administration. Then, insert the following command into the website creation form:
That’s it: our Node.js is reachable and has some handsome Hello World on it.
Discovery planning
Can’t wait to try out an application written in your favorite language? Go ahead, and don’t hesitate to contact our support if you need any help (or to leave a comment on this article to express your joy). If your inspiration is lacking, we’re going to be starting a series of articles on this blog about getting started with hosting applications in different languages.
First up: Node.js, and there’s even a surprise (Node.js’s developers have been soliciting us for so long, they’ve certainly deserved it)…
no comments