flask-cors解决flask 跨域问题

from flask import Flask, render_template,request,jsonify
from flask_cors import CORS

app = Flask(__name__)
CORS(app,  resources={r"/*": {"origins": "*"}})

@app.route('/classify', methods=['POST'])
def classify():
    return {"predict":"hello"}

if __name__ == '__main__':
    app.run(debug=True)

http头记得写

this.$axios.post("http://localhost:5000/classify",this.inputform.content).then(response=>{
        alert(response.data["predict"])
      })

你可能感兴趣的:(flask)