Created
February 26, 2016 23:05
-
-
Save kevboutin/5db2ac61f3d65d54208b to your computer and use it in GitHub Desktop.
Shows how to serve up static files using hapi within node.
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'); | |
const Path = require('path'); | |
const server = new Hapi.Server(); | |
server.connection({ port: 8000 }); | |
// test by using this on browser: | |
// http://localhost:8000/hapi.png | |
server.register(require('inert'), () => { | |
server.route({ | |
method: 'GET', | |
path: '/{param*}', | |
handler: { | |
directory: { | |
path: Path.join(__dirname, 'public') | |
} | |
} | |
}); | |
server.start(() => console.log(`Started at ${server.info.uri}`)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment