Created
March 6, 2018 14:26
-
-
Save andrIvash/6da41d513739c2690a80e1b1ce0605eb to your computer and use it in GitHub Desktop.
hw-node-2_1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const http = require('http'); | |
| const time = 20; | |
| const interval = 1; | |
| const port = 8080; | |
| const server = http.createServer(function(req, res){ | |
| if (req.method === 'GET' && req.url !== '/favicon.ico') { | |
| console.log('********START timer***********'); | |
| const inttime = setInterval(() => { | |
| console.log('echo time = ', Date()); | |
| }, Number(interval * 1000)); | |
| setTimeout(() => { | |
| console.log('********STOP timer***********') | |
| clearInterval(inttime); | |
| res.end(Date()); | |
| }, time * 1000); | |
| } | |
| }); | |
| server.listen(port, () => { | |
| console.log('Server running on port: ' + port); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment