久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      nodejs接口如何傳輸數(shù)據(jù)?

      nodejs接口如何傳輸數(shù)據(jù)?

      視頻教程推薦:node js教程

      最近項目需要接口傳輸,于是乎找了那個選擇哪個語言,選擇node,而且是https模式!
      找了好久才解決跨域問題!廢話不多說,直接上代碼

      let mysql = require('mysql'); let express = require('express'); let app = express(); let https = require("https"); let fs = require("fs"); // Configuare https const httpsOption = {     key : fs.readFileSync("./https/3_jdong.xuexuebang.cn.key"),//https證書key     cert: fs.readFileSync("./https/2_jdong.xuexuebang.cn.crt")//https證書crt } //鏈接數(shù)據(jù)庫 let connection = mysql.createConnection({     host     : '127.0.0.1',     port     : '3306',     database : 'sz',      user     : 'soubei',     password : 'soubei', })  connection.connect();  //解決跨域問題 app.all("*",function (req, res, next) { //允許所有請求方式     res.header("Access-Control-Allow-Origin","*");//所有     res.header("Access-Control-Allow-Headers","content-type")//post     next() })  app.get('/userlist',function(req,res){      shop_name = req.query.shop_name;       connection.query('SELECT * from `order` where orderStatus="暫停" ',function(error,results,fileds){         if(error) throw error;         res.header("Access-Control-Allow-Origin", "*");         res.header('Access-Control-Allow-Headers', 'Content-type');         res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS,PATCH");         res.header('Access-Control-Max-Age',1728000);//預請求緩存20天          res.writeHead(200,{"Content-Type":"text/json;chartset=utf-8"})         data = []          // console.log('SELECT skuId from `cmf_order_sku` where shop_name="'+shop_name+'" group by skuId')            connection.query('SELECT skuId from `cmf_order_sku` where shop_name="'+shop_name+'" group by skuId',function(error,result,fileds){             if (result !=''){                res.end(JSON.stringify(result))              }              if (error == null){                  res.end(JSON.stringify('請求失敗'))             }            })      }) })  https.createServer(httpsOption, app).listen(8080,function(){     // let host = server.address().address;     // let port = server.address().port;     console.log("應用實例,運行在http://%s:%s") });

      效果圖如下

      nodejs接口如何傳輸數(shù)據(jù)?

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號