Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
index.js updated - checking querystring values
- 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.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |