Nodejs on heroku

Heroku is a free service for opening source app development. We actually understand another similar service which is Azure because we study it in INT422.

NodeJS web server

First of all. I need to install express with

$ npm install express --save


Then I need to create a file to provide the information for the server

app.get('/validate/:email', function (req, res) {});

This is function creating a router to for the server

var email =;

This is an example to get some variables.

app.listen(port, function () {});

Finally,  I need to listen to the server.

When all the code have been done. I need to push the code on heroku with

$ git push heroku master
heroku: remote name
master: branch name

Finally, I get this url which is hosting my server, and my lab is done.

This link returns a json file. It means I can do another thing by using this free server.

Creating timetable for this semester

Create a function to return data

exports.time = function (time) {
 switch (time) {
 case 'Tue':
 return { course: [
 { name: 'Unix', time: '8:00', room: 'S2159' },
 { name: 'DCN', time: '11:40', room: 'T3078' },
 { name: 'SOC', time: '2:25', room: 'D3054' },
 return {};

Create a router on the server file

// GET http://localhost:3000/time/:day
app.get('/time/:day', function (req, res) {
 var timeTable = time.time(;


Combine with my app to easily display my time table.

Photo 2017-04-20, 11 34 28 AM.jpg



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s