javascript - Deploying nodejs app on a web server -
i new nodejs , learning, want know how make sample app using nodejs. have tried on localhost , working. trying host public server, not working.
var http = require('http'); http.createserver(function (req, res) { res.writehead(200, {'content-type': 'text/plain'}); res.end('hello world\n'); }).listen(1337, '127.0.0.1'); console.log('server running @ http://127.0.0.1/'); this code saved in local machine m.js, run:
$ node m.js it runs fine , when open in browser https://127.0.0.1:1337
i getting output :
hello world i want same thing remote server i.e. have domain www.example.com , if open https://www.example.com:1337 should show on browser screen :
hello world but not working.
@annanta 127.0.0.1:1337 local machine ip address. please remove this. please find below sample code. try access remote server ipaddress. please note remote machine must have node , npm installed.
var http = require("http"); http.createserver(function(request, response) { response.writehead(200, {"content-type": "text/plain"}); response.write("hello world"); response.end(); }).listen(1337); console.log('server running');
Comments
Post a Comment