Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 674 Bytes

File metadata and controls

38 lines (27 loc) · 674 Bytes

Getting started

Getting started

Start by creating a package.json:

npm init

Install hapi and save it to your package.json dependencies:

npm install hapi --save

Create an index.js file with the following contents:

var Hapi = require('hapi');

// Create a server with a host and port
var server = new Hapi.Server('localhost', 8000);

// Add the route
server.route({
    method: 'GET',
    path: '/hello',
    handler: function (request, reply) {

        reply('hello world');
    }
});

// Start the server
server.start();

Launch the application by running node . and open localhost:8000/hello in your browser.