Basic introduction to Express JS

Express is a web application framework for Node js. I will show you how you can get up and running with express in 5 mins.

First we need nodejs to run the application. You can download this here: http://nodejs.org/

Next you will need to make a new directory where we will put our application.

$ mkdir boom

Go in there and create a package.json file where we will fill out the dependencies of this application. Take note at the express dependency. It’s best to get the latest version of express. You can find this out by going to https://npmjs.org/package/express

{
  "name": "boom",
  "description": "test app",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "3.x"
  }
}

After you have created the package.json you will need to install the projects dependencies with the following command in either terminal or command prompt.

$ npm install

You will see there is now a file named node_modules. This is ok. If you are using version control, be sure to add this as an ignored file.

Now we need to make the application. Create the following file: server.js in your project root and open it in a code editor of your choice.

First we create the application with express();

var express = require('express');
var app = express();

Now we define our routes with app.COMMAND. These are like urls the end user will see. You can see the various commands here. We will use the app.GET command in our script. This has two objects that are passed into the function request and response.

app.get('/hello.txt', function(req, res){
	var body = 'Hello World';
	res.setHeader('Content-Type', 'text/plain');
	res.setHeader('Content-Length', body.length);
	res.end(body);
});

You can see here we are sending the response back to the client with res.end(). We are also setting the Content-Type and Content-Length.

(OPTIONAL) We will assign one more route to make this app slightly exciting. Here we are use a request variable and displaying it in the response.


app.get('/user/:username', function(req, res){
        var body = 'Hello ' + req.params.username;
        res.setHeader('Content-Type', 'text/plain');
        res.setHeader('Content-Length', body.length);
        res.end(body);
});

We then use the app.listen method and assign a port.

app.listen(3000);

Save that file and go back to your terminal or command prompt and start your server with the following:

$ node server.js

you can then navigate to the following http://localhost:3000/hello.txt and you will see your site running.

To see the second route we setup goto http://localhost:3000/user/yourname

Parramasala 2013

Image

Parramasala is an international contemporary arts festival that celebrates the global impact of the arts and cultures of Western Sydney’s communities. The city of Parramatta is home to vibrant arts and entertainment including music, dance, theatre, comedy, film, markets and visual arts from around the world and Parramasala captures this wealth and folds it into a unique cultural event.

IMG_5527 IMG_5530 IMG_5531 IMG_5546 IMG_5550 IMG_5553 IMG_5555 IMG_5556 IMG_5563 IMG_5564 IMG_5565 IMG_5567 IMG_5568 IMG_5572 IMG_5575 IMG_5592 IMG_5607

Lorde – Pure Heroine

Lorde-Pure-Heroine

Pure Heroine is the debut album from New Zealander Ella Yelich-O’Connor, who is better known as Lorde. She was spotted at the young age of 12 singing at a talent show in her hometown near Auckland and subsequently signed to Universal. She shot to prominence in early 2013 with a hugely popular EP, The Love Club, which produced single “Royals.” The record was written with producer Joel Little and showcased her indie-tinged electro-pop sound.