Почему этот код не работает?
Все же вроде верно написано!
index.html:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<title>
Test application!
</title>
</head>
<body>
<form action="index.html" method="POST">
<input type="text" name="first_name" />
<input type="submit" value="Send" />
</form>
</body>
</html>
server.js:
var fs = require("fs");
var index = fs.readFileSync('./index.html');
var http = require('http');
var app = require('express')(),
bodyParser = require('body-parser');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html; charset=utf8'});
res.end(index);
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');
app.use("/index.html", bodyParser.urlencoded({
extended: false
}));
app.post("/index.html", function(req, res, next) {
console.dir(req.body);
console.log(req.body);
res.send('Your name is' + req.body.first_name);
});