Skip to content

Instantly share code, notes, and snippets.

@rasolofonirina
Last active March 25, 2022 12:38
Show Gist options
  • Save rasolofonirina/fc3f97898016dc6cfd756f2d8ba50216 to your computer and use it in GitHub Desktop.
Save rasolofonirina/fc3f97898016dc6cfd756f2d8ba50216 to your computer and use it in GitHub Desktop.
URL with settings
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