jmeter測試 flask 接口請求
阿新 • • 發佈:2019-05-05
eth method print info ask python pre dict mage
jmeter測試 flask 接口請求
flask的代碼如下:
#!/usr/bin/env python # -*- coding: utf-8 -*- from flask import Flask, url_for, request app = Flask(__name__) @app.route(‘/login‘, methods=[‘GET‘, ‘POST‘]) def login(): if request.method == ‘POST‘: print(request.form[‘userid‘]) # 獲取post穿過來的參數dict = request.form.to_dict() # 將請求參數解析成字典 print(dict[‘userid‘]) return ‘POST‘ else: print(request.args[‘userid‘]) # 獲取get傳過來的參數 dict = request.args.to_dict() # 將請求參數解析成字典 print(dict[‘userid‘]) return ‘GET‘ if __name__ == ‘__main__‘: app.run()
運行之後,就可以用jmeter 測試接口了
運行jmeter 查看結果樹:
jmeter測試 flask 接口請求