Node. js processes post requests and node. jspost requests
1. html
2. app. js
Var http = require ('http') var qs = require ('querystring')/*** routing control function * @ param path */function rotuteHandle (request) {if (request. url = '/login' & request. method. toLowerCase () = 'post') {console. log ('Post request for login ') return 'Post method'} return 'get method'}/*** Server returns * @ param request * @ param response */function onRequest (request, response) {request. setEncoding ('utf-8') response. writeHead (200, {'content-type': 'text/plain '}) if (request. url = '/login' & request. method. toLowerCase () = 'post') {var postData = "" request. addListener ('data', function (data) {console. log ('get the post request parameters .. ') postData + = data}) request. addListener ('end', function () {console. log ('Post parameter retrieved successfully') console. log (postData) var content = qs. parse (postData ). text response. write (content) response. end ()} else {response. write ('other method') response. end ()} var server = http. createServer (onRequest) server. listen (3000) console. log ('server is Listening... ')