1-安装篇
-
如果在安装过程中遇到错误,可以点击此链接查看解决方案
-
点击此处官网下载Postman的Linux版本安装包
然后将下载的安装包拖到Ubuntu的桌面中
执行解压命令,注意替换为自己的Postman版本:sudo tar -xzf Postman-linux-x64-6.3.0.tar.gz -C /opt/
执行命令,进入解压后的包:cd /opt/Postman/
执行命令,启动Postman:./Postman
-
安装好后的界面简介
2-配置篇
-
给Postman添加快捷访问方式
执行命令:sudo ln -s /opt/Postman/Postman /usr/bin/postman
执行命令:cat > ~/.local/share/applications/postman.desktop <<EOL
输入下面的代码后,按两次enter键或ctrl+d退出[Desktop Entry] Encoding=UTF-8 Name=Postman Exec=postman Icon=/opt/Postman/app/resources/app/assets/icon.png Terminal=false Type=Application Categories=Development; EOL
-
点击启动器搜索Postman并添加到左侧菜单栏
-
修改字体大小
-
修改主题样式
3-使用篇–以Flask程序中的视图函数做测试
示例一
@app.route("/index, methods=["GET"]")
def index():
city = request.args.get("city")
country = request.args.get("country")
return "city=%s, country=%s" % (city, country)
示例二
@app.route("/index/post1", methods=["POST"])
def index_post1():
name = request.form.get("name")
age = request.form.get("age")
multi = request.form.getlist("multi")
return "name=%s, age=%s, multi=%s" % (name, age, multi)
示例三
@app.route("/index/post2", methods=["POST"])
def index_post2():
print("request.data: %s" % request.data)
return "request.data=%s" % request.data.decode("utf8")
示例四
@app.route("/upload", methods=["POST"])
def upload():
file_obj = request.files.get("pic")
if file_obj is None:
return "未上传任何文件"
file_obj.save("./demo.png")
return "上传成功"