Last active
July 14, 2017 01:14
-
-
Save mattc41190/abb8fa7be6782a2f28e27b217b388e83 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'); // Server tech | |
const Inert = require('inert'); // Hapi plugin for serving static content | |
const PORT = process.env.PORT || 3344; // Port to run my app on | |
const server = new Hapi.Server(); // Create instance of Server | |
server.connection({ port: PORT}); // Add connection to server | |
server.register(Inert, (err) => { | |
if (err) { | |
throw err; | |
} | |
server.route([ | |
{ | |
method: "GET", | |
path: "/", | |
handler: function(request, reply) { | |
reply.file("tommy_big.jpg"); // Serve a picture of tommy at the application root | |
} | |
} | |
]) // Register routes | |
server.start((err) => { | |
if (err) { | |
throw err; | |
} | |
console.log(`Server running at: ${server.info.uri}`); | |
}); // Start the server | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment