Last active
March 25, 2022 12:38
-
-
Save rasolofonirina/fc3f97898016dc6cfd756f2d8ba50216 to your computer and use it in GitHub Desktop.
URL with settings
This file contains 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') | |
const querystring = require('querystring') | |
const server = http.createServer((req, res) => { | |
const settings = querystring.parse(url.parse(req.url).query) | |
res.writeHead(200, {"Content-Type": "text/plain"}) | |
if ('firstname' in settings && 'name' in settings) { | |
res.write('Your name: ' + settings['firstname'] + ' ' + settings['name']) | |
} | |
else { | |
res.write('Please put your firstname and name !') | |
} | |
res.end() | |
}) | |
server.listen(8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment