項目地址https://git.ustclug.org/peter_lee/cppSendPostAndGetToFlaskhtml
from flask import Flask , render_template,request app = Flask(__name__) @app.route('/') def hello_world(): return render_template('index.html') @app.route('/postdata', methods=['POST']) def postdata(): print request.form.get('key1') return "ok" if __name__ == '__main__': app.run()
發送get
請求git
QString url_str = "http://127.0.0.1:5000"; HttpRequestWorker worker; QObject::connect(&worker, SIGNAL(on_execution_finished(HttpRequestWorker*)), &w, SLOT(handle_result(HttpRequestWorker*))); worker.execute(&input);
服務器響應
客戶端響應
flask
發送post
請求服務器
QString url_str = "http://127.0.0.1:5000/postdata"; HttpRequestInput input(url_str, "POST"); input.add_var("key1", "<a><b></b></a>"); HttpRequestWorker worker; QObject::connect(&worker, SIGNAL(on_execution_finished(HttpRequestWorker*)), &w, SLOT(handle_result(HttpRequestWorker*))); worker.execute(&input);
服務器響應
客戶端響應
app