-
-
Save amandeepmittal/2326462903e20cf12a4cf541fe43b45c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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