• 【http】


    var qs = require('querystring')
    require('http').createServer(function(req, res) {
        //res.writeHead(200, {'Content-Type': 'image/png'})
        /*var stream = require('fs').createReadStream('image.png')
        stream.on('data', function(data) {
            res.write(data)
        })
        stream.on('end', function() {
            res.end()
        })*/
        //require('fs').createReadStream('image.png').pipe(res)
    
        if ('/' == req.url) {
            res.writeHead(200, {'Content-Type': 'text/html'})
            res.end([
                '<form method="POST" action="/url">',
                    '<input type="text" name="name">',
                    '<button>Submit</button>',
                '</form>'
            ].join(''))
        } else if ('/url' == req.url && 'POST' == req.method) {
            var body = ''
            req.on('data', function(data) {
                body += data
            })
            req.on('end', function() {
                res.writeHead(200, {'Content-Type': 'text/html'})
                res.end('Content-Type: ' + req.headers['content-type'] + 'Data:' + qs.parse(body).name)
            })
        } else {
            res.writeHead(200, {'Content-Type': 'text/html'})
            res.end('Not Found')
        }
    }).listen(3000)
    
    console.log(qs.parse('name=Guillermo'))
  • 相关阅读:
    Discuz!NT 系统架构分析
    jquery pager
    Nhibernate分页方法
    Discuz nt模板机制
    WTclient创建OPC client方法
    OPC
    Regular Expressions in Java
    How to use VS to manipulate Access
    OPC客户端设计
    How to use VS to manipulate Excel使用MFC读写Excel
  • 原文地址:https://www.cnblogs.com/jzm17173/p/3439439.html
Copyright © 2020-2023  润新知