Skip to content

Commit

Permalink
index.js updated - checking querystring values
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagar authored and Sagar committed Sep 21, 2018
1 parent ad8ee2a commit db8c6ef
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion index.js
@@ -1,7 +1,21 @@
const http = require('http');
const url = require('url');

const app = http.createServer((request,response) => {
console.log('server is running...')
var querystring
querystring = url.parse(request.url,true).query;
if (querystring) {
response.writeHead(200, {"Content-Type": "text/html"});
console.log('the index.js has loaded')
response.write(`<h1>The parsed value from the url is ${querystring.value}</h1>`);
response.end();
}

else {
response.write(`<h1>No values were passed</h1>`);
response.end();
}

})

app.listen(3000);

0 comments on commit db8c6ef

Please sign in to comment.