0.3.2 • Published 4 years ago
wait-html v0.3.2
Funny
don't forget to wrap each function with async keyword
'use strict';
const port = 8000;
const http = require('http');
const url = require('url');
const Wait = require('wait-html');
const app = http.createServer(async (req, res) => {
let uri = url.parse(req.url, true);
if(uri.pathname === '/render'){
let body = await Wait.render('html/render.html');
res.writeHead(200, {'Content-Type' : 'text/html'});
res.end(body);
}
else{
res.writeHead(200, {'Content-Type' : 'text/html'});
res.end('Wait Html Root page.');
}
});
app.listen(port, () => {
console.log(`Server Up On Port => ${port}.`);
});
0.3.2
4 years ago