0.0.1 • Published 3 years ago

wait-for-html v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Funny

don't forget to wrap each function with async keyword

'use strict';
const port = 3000;
const http = require('http');
const url = require('url');
const path = require('path');
const Wait = require('wait-for-html');
const html = path.resolve('html');

Wait.path(html);

const app = http.createServer(async (req, res) => {
	let uri = url.parse(req.url, true);
	if(uri.pathname === '/render'){
		let body = await Wait.render('/render');
		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.0.1

3 years ago