Make it embeddable as standalone

This commit is contained in:
Alex Hultman 2018-11-04 09:01:51 +01:00
parent 4ccdc569d8
commit bfad8bf232
3 changed files with 132 additions and 0 deletions

16
examples/HelloLoopery.js Normal file
View file

@ -0,0 +1,16 @@
/* This is a script not for Node.js but runs completely stand-alone using loopery */
print('Welcome to loopery!');
const port = 3000;
App().get('/hello', (res, req) => {
res.end('world!');
}).get('/*', (res, req) => {
res.writeHeader('content-type', 'text/html; charset= utf-8').end(req.getHeader('user-agent') + ' är din user agent, biatch!');
}).listen(port, (token) => {
if (token) {
print('Listening to port ' + port);
} else {
print('Failed to listen to port ' + port);
}
});