Created
February 11, 2022 22:43
-
-
Save karl-gustav/61a2332ad19da596032bfbcb6222f4a4 to your computer and use it in GitHub Desktop.
Minimal pure node js server
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 url = require('url'); | |
function handler(req, res) { | |
res.writeHead(200, {'Content-type':'text/plain'}); | |
res.write('Hello, I am a webserver !'); | |
res.end(); | |
} | |
const port = process.env.PORT || 8080; | |
console.log('Server listening on http://localhost:'+port); | |
const server = http.createServer(handler); | |
server.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment