How to call the background interface through HTML to solve the problem of requesting python interface background crossing. Please see the front-end code
var x = document.getElementById("audio");
var settings = {
"url": "http://url:2222/kbn/?text="+a,
"method": "GET",
};
$.ajax(settings).done(function (response) {
x.src=response.mp3;//赋值
});
Python background install module to solve.
pip install flask_cors #安装模块
from flask_cors import *
app = Flask(__name__)
CORS(app, supports_credentials=True)#解决跨越问题
Welcome to follow us!