Skip to content

Instantly share code, notes, and snippets.

@jcenturion jcenturion/sample.js
Last active Aug 29, 2018

Embed
What would you like to do?
'use latest'
import express from 'express';
import { fromExpress } from 'webtask-tools';
import bodyParser from 'body-parser';
const app = express();
app.get('/', (req, res) => {
const HTML = renderView({
title: 'Sample extension',
body: '<h1>Welcome to your extension</h1>'
});
res.set('Content-Type', 'text/html');
res.status(200).send(HTML);
});
module.exports = fromExpress(app);
function renderView(locals) {
return `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>${locals.title}</title>
</head>
<body>
${locals.body}
</body>
</html>
`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.