You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
336 B
20 lines
336 B
|
3 years ago
|
const kill = require('./')
|
||
|
|
const http = require('http')
|
||
|
|
const port = 8080
|
||
|
|
|
||
|
|
const server = http.createServer((req, res) => {
|
||
|
|
res.writeHead(200, {
|
||
|
|
'Content-Type': 'text/plain'
|
||
|
|
})
|
||
|
|
|
||
|
|
res.end('Hi!')
|
||
|
|
})
|
||
|
|
|
||
|
|
server.listen(port, () => {
|
||
|
|
setTimeout(() => {
|
||
|
|
kill(port)
|
||
|
|
.then(console.log)
|
||
|
|
.catch(console.log)
|
||
|
|
}, 1000)
|
||
|
|
})
|