var Hapi = require('hapi');
// Create a server with a host and port
var server = new Hapi.Server('localhost', 8000);
// Define the route
var hello = function (request) {
request.reply({ greeting: 'hello world' });
};
// Add the route
server.addRoute({
method: 'GET',
path: '/hello',
handler: hello
});
// Start the server
server.start();
With jsonp support, if the user hits http://localhost:8000/hello?jsonp=nice, the server responds with
nice({ greeting: 'hello world' });
This jsonp support can be switched off with config during server instantiating.
With jsonp support, if the user hits
http://localhost:8000/hello?jsonp=nice, the server responds withThis jsonp support can be switched off with config during server instantiating.