Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created October 17, 2018 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepmittal/2326462903e20cf12a4cf541fe43b45c to your computer and use it in GitHub Desktop.
Save amandeepmittal/2326462903e20cf12a4cf541fe43b45c to your computer and use it in GitHub Desktop.
'use strict';
const Hapi = require('hapi');
// Create a server with a host and port
const server = Hapi.server({
host: 'localhost',
port: 8000
});
// Add the route
server.route({
method: 'GET',
path: '/',
handler: (request, h) => {
return 'hello world';
}
});
// Start the server
async function start() {
try {
await server.start();
} catch (err) {
console.log(err);
process.exit(1);
}
console.log('Server running at:', server.info.uri);
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment