I'm trying to upload two node.js files to koding.com and run them.
index.js contains:
var server = require("./server");
server.start();
And server.js
var http = require("http");
var url = require("url");
function start() {
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(6665, '0.0.0.0');
console.log("Server has started.");
}
exports.start = start;
I typed in vm terminal jstq@vm-0:~$ node Web/IkapNodeJS/index.js
it gives me Server has started.
If im going to http://jstq.kd.io/IkapNodeJS/index.js - i see index.js contains.
When im adding :6665 to that url - url not found.
How do i see page with hello world?
If you're running your application on 6665, the you would access it with http://jstq.kd.io:6665/. You should see your Hello world there.
Node does not run like a cgi script; you don't point to the file to run it, you run it with a process (node). When the server is running on a specific port, the content will be available on any address/hostname that points to that machine so long as you specify the proper port.
HTH, Aaron