版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
HTTP觀察HTTPcurl-v////consthttp=require("http");constfs=require("fs");.createServer((req,res){const{method,url}=if(method=="GET"&&url=={fs.readFile("./index.html",(err,data)=>{res.setHeader("Content-Type","text/html");}elseif(method=="GET"&&url=={res.setHeader("Content-Type","application/json");res.end(JSON.stringify([{name:"tom",age:20}////<script(async()=>constres=awaitaxios.get("/api/users") n(`Response:constconstimg=newImage()constexpress=require('express')constapp=express()app.use(express.static(dirname+'/'))module.exports=////constapi=require('./api') =require('./ 或者通過baseURLaxios.defaults.baseURL='!響應(yīng)簡單請求動詞為get/post/head,沒有自定義請求頭,Content-Type是application/x-www-resres.setHeader('Access-Control-Allow-Origin',////axios.defaults.baseURL=elseelseif(method=="OPTIONS"&&url=={res.writeHead(200,"Access-Control-Allow-Origin":" "Access-Control-Allow-Headers":"X-Token,Content-Type","Access-Control-Allow-Methods":"PUT"}//index.html//index.html//http-",{foo:'bar'},elseif((method=="GET"||method=="POST")&&url=="/users")////預(yù)檢options中和/users// ', ////觀 ajax)axios.defaults.withCredentials=varvarexpress= = constapp=app.use(express.static(dirname+module.exports=({target:',changeOrigin:對比一下nginx與wck//vue.config.js//vue.config.jsmodule.exports={{disableHostCheck:true,compress:true,port:5000,:'/api/':{target:'changeOrigin:}serverserver #server_namelocation/{ indexindex.htmlindex.htm;try_files$uri$uri//index.html;}location/api X-Forwarded-For}};application/x-www-form-<form<formaction="/api/save"<inputtype="text"name="abc"<inputtype="submit"http:////elseif(method==="POST"&&url==={letreqData=[];letsize=0;req.on('data',data=>{console.log('>>>reqon',data);size+=req.on('end',function{constdata=Buffer.concat(reqData,size);console.log('data:',size,data.toString())}awaitawaitaxios.post("/api/save",a:b://模擬application/x-www-form-urlencodedawaitaxios.post("/api/save"'a=1&b=3'headers:'Content-Type':'application/x-www-form-//Streampipe//Streampipe//Bufferconnectrequest//Bufferconnectrequest.on('data',data=>{size+=data.lengthconsole.log('data:',datarequest.on('end',()=>constbuffer=Buffer.concat(chunk,size)size=0// request.on('data',datarequest.on('end',(){fis.end()////constoriginRequest=constcheerio=require("cheerio");consticonv=require("iconv-functionrequest(url,{constoptions={url:url,encoding:nulloriginRequest(url,}forfor(leti=100553;i<100563;i++)consturl=`http request(url,function(err,res,body){consthtml=iconv.decode(body,"gb2312");const$=cheerio.load(html);console.log($(".title_allh1").text());}////constnet=constchatServer=net.createServer() List=[] =>{ .on('data',data=>{List.forEach(v=>{netnetlocalhostHttp<script<script<div<inputv-<buttonv-on:click="send">發(fā)送<buttonv-on:click="clear">清空<divv-for="iteminconsthost='varapp=newVue({el:'#app',data:{list:message:'omethods:send:asyncfunction()letres=awaitaxios.post(host+{message:this.list=clear:asyncfunction()letres=awaitaxios.post(host+'/clear')this.list=res.data}mounted:function{setInterval(async()=>constres=awaitaxios.get(host+'/list')this.list=res.data},}constconstexpress=require('express')constapp=express()constbodyParser=require('body-constpath=constlist=['ccc',app.get('/list',(req,res){)app.post('/send',(req,res)app.post('/clear',(req,res){list.length=0npminstallsave服務(wù)端:chat-varapp=varhttp=require('http').Server(app);vario=require('socket.io')(http);app.get('/',function(req,res){res.sendFile(dirname+function(socket){console.log('ausersocket.on('chatfunction(msg){console.log('chat+io.emit('chatmessage',function(){console.log('userfunction(){console.log('listeningon*:3000');<!DOCTYPE<title>Socket.IO*margin:padding:box-sizing:border-}bodyfont:13pxHelvetica,}formbackground:#000;padding:3px;position:fixed;bottom:0;width:}form{border:0;padding:10px;width:90%;margin-right:}form{width:background:rgb(130,224,255);border:none;padding:}#messageslist-style-type:none;margin:0;padding:}#messages{padding:5px}}#messagesli:nth-{background:}<ul<form<input plete="off"<script$(function()varsocket=e.preventDefaultsocket.emit("chatmessage",returnfalse;socket.on("chatmessage",function(msg)WebSocketoverFLashXHRPollingXHRMultipartStreamingForeverIframeJSONPopensslgenrsa-outprivatekey.pem1024#創(chuàng)建 opensslreq-new-keyprivatekey.pem-out#獲 opensslx509-req-incertrequest.csr-signkeyprivatekey.pem-#創(chuàng)建pfx文件opensslpkcs12-export- .pem-inkeyprivatekey.pem-多路復(fù)用-雪碧圖、多CDN、接口合并演示-https: http/1.x的header由于和
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 承攬房屋裝修工程合同
- 房地產(chǎn)轉(zhuǎn)讓合同集錦
- 兼職勞務(wù)合同
- 人力資源服務(wù)合同
- 德漢翻譯服務(wù)合同
- 節(jié)能設(shè)備購銷合同協(xié)議
- 禽蛋類采購合同
- 物業(yè)管理市場分析與競爭策略
- 爆破工程技術(shù)服務(wù)合同
- 軟件銷售代理合作合同
- 全國大學(xué)生英語競賽詞匯大綱
- 情緒障礙跨診斷治療的統(tǒng)一方案
- 聚焦幼兒作品分析的游戲觀察與評價(jià)
- 胸外科手術(shù)圍手術(shù)期處理
- 《企業(yè)管理課件:團(tuán)隊(duì)管理知識點(diǎn)詳解PPT》
- 配網(wǎng)設(shè)備缺陷分類及管理重點(diǎn)標(biāo)準(zhǔn)
- 反腐倡廉廉潔行醫(yī)
- UI與交互設(shè)計(jì)人機(jī)交互設(shè)計(jì)(第二版)PPT完整全套教學(xué)課件
- 《插畫設(shè)計(jì)》課程標(biāo)準(zhǔn)
- 高考作文答題卡(作文)
- 在鄉(xiāng)村治理中深化推廣運(yùn)用清單制、積分制、一張圖工作方案
評論
0/150
提交評論