response

vue-cli配置axios

点点圈 提交于 2020-01-13 08:19:00
"use strict" ; import Vue from 'vue' ; import axios from "axios" ; import VueAxios from 'vue-axios' // Full config: https://github.com/axios/axios#request-config // axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || ''; // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; let config = { // baseURL: process.env.baseURL || process.env.apiUrl || "" // timeout: 60 * 1000, // Timeout // withCredentials: true, // Check cross-site Access-Control } ; const _axios = axios . create (

response.setHeader各种用法详解

允我心安 提交于 2020-01-13 05:27:45
一秒刷新页面一次 response.setHeader("refresh","1"); 二秒跳到其他页面 response.setHeader("refresh","2;URL=otherPagename"); 没有缓存: response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); 设置过期的时间期限 response.setDateHeader("Expires", System.currentTimeMillis()+自己设置的时间期限); 访问别的页面:response.setStatus(302); response.setHeader("location","url"); 通知浏览器数据采用的压缩格式:response.setHeader("Content-Encoding","压缩后的数据"); 高速浏览器压缩数据的长度:response.setHeader("Content-Length",压缩后的数据.length+""); 高速浏览器图片或视频:response.setHeader("Content-type","这个参数在tomcat里conf下的web.xml里面找"); inputstream in= this

利用Servlet生成动态页面

孤人 提交于 2020-01-13 01:54:00
创建Web项目HelloServletWorld 在web目录里创建首页文件index.html 在src目录里创建net.xmh.servlet包,在里面创建HelloServletWorld类 package net.cw.servlet; import javax.servlet.ServletException; import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Date; @WebServlet(name = "HelloServletWorld", value = "/hello", initParams = { @WebInitParam(name =

axios拦截器

六月ゝ 毕业季﹏ 提交于 2020-01-12 21:47:41
我们在做一些项目的时候都会有一个登陆页面和很多的详情的页面,包括我们现在看到的很多的页面也是一样的,但是,如果说我们在还没有登录的时候,详情等其他的页面就开始报出重大的错误,那么我们肯定不能够展现给我们的用户看,因为一旦有报错,我们的一些功能一些页面都是报红根本就看不了,所以当报错的时候我们还是返回登录页面并且给用户提示,这个时候我们就用到了我们的 axios拦截器 . axios拦截器能够更好的帮我们处理这个问题,axios拦截器在任何的框架中也是很受欢迎的所以我们在那个框架中都可以进行使用只是我们存放的文件位置不一样,我们先说一下进行安装axios的命令: npm install axios --save 这个命令不管是react,还是Vue都可以使用,我们先看一下react的文件结构: 我 们的文件结构就是这样,vue的也可以这样放,我们下面来看一下代码: import axios from 'axios' // axios 配置 axios.defaults.timeout = 5000 axios.defaults.baseURL = '' // http request 拦截器 axios.interceptors.request.use( config => { // config.headers.Authorization = `token ${store

day5-requests的post方法

帅比萌擦擦* 提交于 2020-01-12 14:50:11
1.初步接触post 1.requests的POST请求 ''' # 1.访问login页面获取token信息 Request URL: https://github.com/login Request Method: GET #服务端告诉客户端需要设置的Cookies 响应头(response headers): Set-Cookies 请求头(request headers): Cookie User-Agent ''' headers ={'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Safari/537.36' } import requests import re url1='https://github.com/login' response = requests.get(url1,headers=headers) #把login页返回的cookie信息转换为字典 login_cookies =response.cookies.get_dict() #print(login_cookies) """ 正则:<input type="hidden" name="authenticity

Node.js创建第一个应用

自古美人都是妖i 提交于 2020-01-12 08:16:23
此篇随笔只是想记载一下 怕哪天自己给瓦掉... 第一步当然是下载Node了 地址:https://nodejs.org/en/download/ 下载之后确认确认确认就好 第二步就是确认我们是否安装成功,打开我们的命令提示符输入 node -v回车就会出现我们安装的版本 再输入 npm -v回车 也是出现版本 如图 第三步打开我们的编辑器 (我用的是Sublime) 创建文件 (官网上扒的...) 内容: var http = require('http'); http.createServer(function (request, response) { // 发送 HTTP 头部 // HTTP 状态值: 200 : OK // 内容类型: text/plain response.writeHead(200, {'Content-Type': 'text/plain'}); // 发送响应数据 "Hello World" response.end('Hello World\n'); }).listen(8888); // 终端打印如下信息 console.log('Server running at http://127.0.0.1:8888/'); 不要忘记保存哟,取名字就看你们的心情了。 好!这个时候就是精彩时刻,打开所在文件夹 鼠标点击一下文件 然后按住Shift键

Chrome -> Inspect element -> Network (XHR) -> Preview Tab (HTML) issue

江枫思渺然 提交于 2020-01-12 08:05:18
问题 I am having a problem with that preview tab in network section. When HTML is returned I am seeing the raw HTML in both preview and response. Sometimes, but very rarely, I HTML is rendered properly in Preview tab. Am I doing something wrong or it's just some Chrome bug? Thanks 回答1: I was testing this as well. What did it for me was adding the http header. header('HTTP/1.1 500 Internal Server Error'); Then of course some proper markup formatting. But the status code was what I needed to

Chrome -> Inspect element -> Network (XHR) -> Preview Tab (HTML) issue

与世无争的帅哥 提交于 2020-01-12 08:05:10
问题 I am having a problem with that preview tab in network section. When HTML is returned I am seeing the raw HTML in both preview and response. Sometimes, but very rarely, I HTML is rendered properly in Preview tab. Am I doing something wrong or it's just some Chrome bug? Thanks 回答1: I was testing this as well. What did it for me was adding the http header. header('HTTP/1.1 500 Internal Server Error'); Then of course some proper markup formatting. But the status code was what I needed to

ajax、axios、fetch的区别

纵饮孤独 提交于 2020-01-12 06:55:55
1. ajax 使用步骤 创建 XmlHttpRequest 对象 调用 open 方法设置基本请求信息 设置发送的数据,发送请求 注册监听的回调函数 拿到返回值,对页面进行更新 //1.创建Ajax对象 if ( window . XMLHttpRequest ) { var oAjax = new XMLHttpRequest ( ) ; } else { var oAjax = new ActiveXObject ( 'Microsoft.XMLHTTP' ) ; } //2.连接服务器(打开和服务器的连接) oAjax . open ( 'GET' , url , true ) ; //3.发送 oAjax . send ( ) ; //4.接收 oAjax . onreadystatechange = function ( ) { if ( oAjax . readyState == 4 ) { if ( oAjax . status == 200 ) { //alert('成功了:'+oAjax.responseText); fnSucc ( oAjax . responseText ) ; } else { //alert('失败了'); if ( fnFaild ) { fnFaild ( ) ; } } } } ; 优缺点: 本身是针对MVC的编程

Python爬虫5.3 — scrapy框架spider[Request和Response]模块的使用

杀马特。学长 韩版系。学妹 提交于 2020-01-12 02:38:37
Python爬虫5.3 — scrapy框架spider[Request和Response]模块的使用 综述 Request对象 scrapy.Request()函数讲解: Response对象 发送POST请求 模拟登陆 模拟登陆人人网 其他博文链接 综述 本系列文档用于对Python爬虫技术的学习进行简单的教程讲解,巩固自己技术知识的同时,万一一不小心又正好对你有用那就更好了。 Python 版本是3.7.4 我们在前面学习reuqests库的时候是如何进行翻页请求的?首先找到下一页地址,然后再使用 requests.get(next_url) 进行请求获取。那么我们在Scrapy框架中如何对下页进行构造请求的呢?本篇讲解如何构造请求模块。 Request对象 在第一篇入门文章中我们已经在爬取糗百实例中实现了下一页请求获得的功能在爬虫中增加下面代码即可: # 获取下一页地址 next_url = response . xpath ( '//ul[@class="pagination"]/li[last()]/a/@href' ) . get ( ) if not next_url : # 没有下一页地址结束爬虫 return else : # 将下一页请求返回给调度器 yield scrapy . Request ( self . base_url + next_url ,