/** * Created by os on 17-6-18. */ var express = require('express') // var http = require('http') var fs = require('fs') var app = express() app.get('/index.html',function(req,res){ res.sendfile(__dirname+'/index.html') // res.send('hello world') }) app.post('/index.html',function(req,res){ req.on('data',function(data){ var obj = data.toString() console.log(obj) res.send(data.toString()) }) }) app.listen(8889,'127.0.0.1') <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> 山丘 <form action="index.html" method="post"> <input type="text" name="username" placeholder="请输入姓名"><br> <input type="text" name="age" placeholder="请输入年龄"><br> <input type="submit" value="提交"> </form> </body> </html>