File size: 673 Bytes
d260728
21f8e20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d260728
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require('http').createServer(async(res,req)=>{
  var urlObject = new URL('http://' + req.headers['host'] + req.url)
  var code = querystring.parse(urlObject.search.length > 1 ? urlObject.search.substr(1) : "");
  if(!code){
    code = await new Promise((resolve) => {
				let body = [];
				req.on('data', chunk => {
					body.push(chunk);
				}).on('end', () => {
					resolve(Buffer.concat(body).toString());
				}).on('error', () => {
					resolve(Buffer.concat(body).toString());
				})
			})
  }
  if(!code) return res.end('no code!');
  var resp = await eval(`async(res,req)=>{${code}}`)(res,req);
  if(resp && !res.finished ) return res.end(""+resp);
}).listen(7860)