Я новичок в nodejs.Здесь метод сообщения не работает.Поэтому мне нужна помощь.
ниже - мой файл .js.
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({
extended: true
}));
app.listen(1465, function() {
console.log('listeninggg at port 1465');
});
app.get('/hello', function(req, res) {
res.sendFile(__dirname + "/" + "index4.html");
});
app.post('/hello', function(req, res) {
res.send('You sent the name "' + req.body.user_name + '".');
});
ниже - мой файл html.
<html>
<body>
<form action="localhost:1465/hello" method="POST">
First Name: <input type="text" name="user_name"> <br>
<input type="submit" value="Submit">
</form>
</body>
</html>