From bb5c0b85d95c40ee130731cc8d81fe985c0ef861 Mon Sep 17 00:00:00 2001 From: HexToString <506181616@qq.com> Date: Mon, 2 Aug 2021 11:12:02 +0000 Subject: [PATCH] add http client --- python/examples/fit_a_line/README_CN.md | 22 +++++-------------- python/examples/fit_a_line/test_httpclient.py | 3 ++- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/python/examples/fit_a_line/README_CN.md b/python/examples/fit_a_line/README_CN.md index d58eb4fb..20e3c5d6 100644 --- a/python/examples/fit_a_line/README_CN.md +++ b/python/examples/fit_a_line/README_CN.md @@ -10,15 +10,16 @@ sh get_data.sh -## RPC服务 -### 开启服务端 +## 开启服务端 ```shell python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 ``` -### 客户端预测 +## 客户端预测 + +### 客户端RPC `test_client.py`中使用了`paddlepaddle`包,需要进行下载(`pip install paddlepaddle`)。 @@ -26,23 +27,12 @@ python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --po python test_client.py uci_housing_client/serving_client_conf.prototxt ``` - - -## HTTP服务 - -### 开启服务端 - -通过下面的一行代码开启默认web服务: +### 客户端Http预测 ``` shell -python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --name uci +python test_httpclient.py uci_housing_client/serving_client_conf.prototxt ``` -### 客户端预测 - -``` shell -curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}' http://127.0.0.1:9393/uci/prediction -``` ## 性能测试 ``` shell diff --git a/python/examples/fit_a_line/test_httpclient.py b/python/examples/fit_a_line/test_httpclient.py index 6826068a..cd993042 100644 --- a/python/examples/fit_a_line/test_httpclient.py +++ b/python/examples/fit_a_line/test_httpclient.py @@ -20,7 +20,8 @@ import time client = HttpClient() client.load_client_config(sys.argv[1]) -client.use_key("./key") +# if you want to enable Encrypt Module,uncommenting the following line +#client.use_key("./key") client.set_response_compress(True) client.set_request_compress(True) fetch_list = client.get_fetch_names() -- GitLab