Skip to content

Instantly share code, notes, and snippets.

@dsathyakumar
Created March 29, 2023 08:14
Show Gist options
  • Save dsathyakumar/a8c357f0f0c12fe3cc6ddefbe58f1977 to your computer and use it in GitHub Desktop.
Save dsathyakumar/a8c357f0f0c12fe3cc6ddefbe58f1977 to your computer and use it in GitHub Desktop.
require('marko/node-require').install();
const http = require('http');
const server = require('http').createServer();
const port = 8080;
const indexTemplate = require('./index.marko');
server.on('request', (req, res) => {
var out = require('async-writer').create(res);
out.write('<h1>------Before body--------</h1>');
indexTemplate.render({
name: 'Frank',
count: 30,
colors: ['red', 'green', 'blue']
}, out);
out.write('<h1>------After body--------</h1>');
out.end();
});
server.listen(port, () => {
console.log(`Successfully started server on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment