Skip to content

Instantly share code, notes, and snippets.

@jcenturion
Last active August 29, 2018 15:51
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 jcenturion/ce82e367ab1ded2915232871f596dc20 to your computer and use it in GitHub Desktop.
Save jcenturion/ce82e367ab1ded2915232871f596dc20 to your computer and use it in GitHub Desktop.
'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