Skip to content

Instantly share code, notes, and snippets.

@m-cakir
Last active April 8, 2018 11:47
Show Gist options
  • Select an option

  • Save m-cakir/36be10a5444799c96da08b717a9c379f to your computer and use it in GitHub Desktop.

Select an option

Save m-cakir/36be10a5444799c96da08b717a9c379f to your computer and use it in GitHub Desktop.
Hapi quick example
'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:'/hello',
handler: function (request, h) {
return h.response({
message : '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