跟iis 里是否设置http响应标头没有关系。不设置也可以正常获取到
https://www.jianshu.com/p/212ecf096023
#coding:utf-8
from flask.wrappers import Response
import xlrd
import MySQLdb
import arcpy
import time
import datetime
from arcpy import env
from flask_cors import CORS
import sys
import io
import json
from flask import Flask, jsonify, abort, request
app = Flask(__name__)
cors = CORS(app, supports_credentials=True)
app = Flask(__name__)
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization,session_id')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS,HEAD')
# 这里不能使用add方法,否则会出现 The 'Access-Control-Allow-Origin' header contains multiple values 的问题
response.headers['Access-Control-Allow-Origin'] = '*'
return response
@app.route('/helloworld')
def hello_world():
return 'Hello, World!'
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5050)