--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/App1.js Tue Sep 23 01:06:00 2014 +0100
@@ -0,0 +1,27 @@
+var express = require('express');
+var bodyParser = require('body-parser');
+
+var app = express();
+app.use(bodyParser.urlencoded({ extended: true }));
+
+// sending the form
+app.get('/', function(req, res){
+ var html = '<form action="/" method="post">' +
+ 'Login: <input type="text" name="login" /><br>' +
+ 'Password: <input type="password" name="pass" /><br>' +
+ '<button type="submit">Submit</button>' +
+ '</form>';
+ res.send(html);
+});
+
+// receiving data
+app.post('/', function(req, res){
+ var html = 'Received login: ' + req.body.login + '<br>' +
+ 'Received password: ' + req.body.pass + '<br>' +
+ '<a href="/">Try again</a>';
+ res.send(html);
+});
+
+// starting the server
+app.listen(8000);
+console.log("Server running at http://127.0.0.1:8000/");
\ No newline at end of file