Add 'js/http.js'

This commit is contained in:
Sarimoko 2022-02-19 11:25:11 +00:00
parent 55fb395366
commit 6166edba92
1 changed files with 14 additions and 0 deletions

14
js/http.js Normal file
View File

@ -0,0 +1,14 @@
const http = require('http')
const hostname = '127.0.0.1'
const port = 3000
const server = http.createServer((req, res) => {
res.statusCode = 200
res.setHeader('Content-Type', 'text/plain')
res.end('Hello World\n')
})
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`)
})