gRPC实战_区块链应用集成测试 - 然后,编写以下Python代码:
requestsrequests
pip install requests 拼多多帮助力入口
然后,编写以下Python代码:
import requests
from blockchain_server import BlockchainServiceServicer
def main():
client = requests.Session()
# 构造请求体
request_body = {
"blockHash": "your_block_hash"
}
# 发送请求
response = client.post("http://localhost:50051/blockchain_server.pb.go/GetLatestBlock", json=request_body)
# 解析响应
result = response.json()
print(result)
if __name__ == "__main__":
main()
your_block_hash