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