Monday, 17 April 2017

How to run a code after a server is started?

I have a server setup as follows:

var http = require('http'); 
var open = require('open') 
http.createServer(function(request, response) {

}).listen(3000)
open('http://localhost:3000','Firefox')

I am using the open module to open the url with firefox.This works but how do i know that firefox opens the url after the server has started? Is http.createServer not an asynchronous call? I wanna make sure it opens after the server is started.Thanks!



via Anantha Padmanaban

No comments:

Post a Comment