JSFiddle - React, Tailwind, and code Playground
HTML
<title>Hello {{name}}</title>
<body>
Hello {{name}}
</body>
JavaScript
'use strict';
const Hapi = require('hapi');
const Path = require('path');
// Create a server with a host and port
const server = new Hapi.Server();
server.connection({
host: 'localhost',
// server that listens on port 8080 , if none is passed from the command line
port: Number(process.argv[2] || 8080)
});
// Add the route
server.register(require('Vision'), (err) => {
if (err) {
throw err;
}
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply.view('index', { name: request.query.name })
}
});
server.views({
engines: {
html: {
module: require('handlebars')
}
},
path: Path.join(__dirname, 'templates')
});
});
// Start the server
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});