Skip to content

Instantly share code, notes, and snippets.

@mattc41190
Last active July 14, 2017 01:14
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 mattc41190/abb8fa7be6782a2f28e27b217b388e83 to your computer and use it in GitHub Desktop.
Save mattc41190/abb8fa7be6782a2f28e27b217b388e83 to your computer and use it in GitHub Desktop.
'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