烧瓶代码:
from flask import Flask,jsonify, send_from_directory, render_template, redirect, request, session,url_for
app = Flask(__name__)
@app.route('/apix',methods=["POST","GET"])
def apix():
if request.form.get('test'):
return "OK"
else:
return "NO"
if __name__ == '__main__':
app.run(host="0.0.0.0", port=1000,debug=True)
阿贾克斯:
let datax = {test:'<img width="500px" src="image.png">'}
$.ajax( {
url: '/apix',
type: 'POST',
data: datax,
processData: false,
contentType: false
} ).done(function (data) {
if (data=="OK"){
alert("OK
}
else{
alert('NO');
}
});
当我将 html 代码发送到 /apix 时,它应该接受并返回“OK”。
<" is the issue. Can you pass it as a string for this application?