Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Installation
- Install the dependencies
- ```
- npm install express --save
- npm install body-parser --save
- npm install cookie-parser --save
- npm install multer --save
- ```
- and now you can run
- ```
- node server.js
- ```
- -----------------------------------------------------------------
- var express = require('express');
- var app = express();
- app.get('/', function(req, res) {
- var t = randomInt(1000, 2000);
- sleep(t, function () {
- res.send('' + t);
- });
- });
- function randomInt(min, max) {
- return Math.floor(Math.random() * (max - min)) + min;
- }
- function sleep(time, callback) {
- var stop = new Date().getTime();
- while(new Date().getTime() < stop + time) {
- }
- callback();
- }
- var server = app.listen(8081, function () {
- var host = server.address().address;
- var port = server.address().port;
- console.log("Example app listening at http://%s:%s", host, port);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement