Advertisement
Guest User

node single thread example

a guest
Oct 5th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const http = require('http');
  2. const url = require('url');
  3.  
  4. const port = 8888;
  5.  
  6. http.createServer((request, response) => {
  7.   let currentPath = url.parse(request.url).pathname;
  8.  
  9.   switch (currentPath) {
  10.     case '/hang':
  11.       var i = 0;
  12.  
  13.       while (i < 9000000000) {
  14.         i += 1;
  15.       }
  16.  
  17.       response.write(currentPath);
  18.       response.end();
  19.  
  20.       break;
  21.  
  22.     default:
  23.       response.write(currentPath);
  24.       response.end();
  25.   }
  26. }).listen(port);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement