Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const http = require('http');
- var url = require('url');
- var fs = require('fs');
- const hostname = '127.0.0.1';
- const port = 3000;
- const server = http.createServer((req, res) => {
- if(req.url =='/jci.html'){
- var data = fs.readFileSync('jci.html');
- res.writeHead(200, { 'Content-Type': 'text/html' });
- res.write(data)
- return res.end();
- }
- var queryObject= url.parse(req.url, true);
- var userData = queryObject.query;
- if(userData.userName =='balram' && userData.password=='chavan'){
- res.writeHead(200, { 'Content-Type': 'text/html' });
- res.write('<h1>Login successful</h1>')
- return res.end();
- }
- else{
- res.writeHead(400, { 'Content-Type': 'text/html' });
- res.write('<h1>Login failed</h1>')
- return res.end();
- }
- });
- server.listen(port, hostname, () => {
- console.log(`Server running at http://${hostname}:${port}/`);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement