-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
40 lines (32 loc) · 1.09 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var port = process.env.PORT || 3000;
// create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })
var login = require('./Profile');
app.get('/', function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
// return res.sendStatus(200);
res.end('hello this is home');
// res.end(JSON.stringify({ Hello: 'World' }));
});
app.get('/Contact', function (req, res) {
res.end('hello this is contact');
});
app.post('/Profile', urlencodedParser, function (req, res) {
if (!req.body) {
return res.sendStatus(400)
} else {
console.log('request ', req.body);
var name = req.body.name;
var password = req.body.password;
var value = login(name, password);
res.end(JSON.stringify(value));
}
});
// app.listen(3000);
// console.log('yo yo listening to localhost default port');
app.listen(port, function () {
console.log('yo yo listening to localhost default port');
});