mock一个服务
python 版本
from flask import jsonify, Flaskapp = Flask(__name__)
# 增加配置,支持中文顯示
app.config['JSON_AS_ASCII'] = False
tasks = {
"success": "true",
"resultMsg": "請求成功",
"result": "1000"
}
@app.route('/task', methods=['GET','POST'])
def get_task():
return jsonify(tasks)
if __name__ == '__main__':
app.run(
host = '0.0.0.0',
port = 6868,
debug = True
)
node版本
var data = {
"code": 0, "message": "success" }
var http = require('http'); http.createServer(function(request,response){ response.writeHead(200,{'Content-Type':'application/json'}); response.end(JSON.stringify(data)); } ).listen(8888); console.log('Server running at http://127.0.0.1:8888/'); 這兩種方法都可以模擬一個外部服務(wù)
轉(zhuǎn)載于:https://www.cnblogs.com/lizzzzz/p/11052916.html
總結(jié)
- 上一篇: OO Unit4 UML
- 下一篇: 什么是软件测试架构师?