Skip to main content

Transmit Server & Client use thrift

Project description

Transmit Server & Client

Install

pip install transmit

Usage

Server

from server import Server

class TestServer(Server):
    def __init__(self,port=18100):
        super().__init__(port)

    def test_function(self,msg):
        print('Testing:',msg)
        return {"say":"Happy everyday!!!"}

if __name__ == '__main__':
    ts = TestServer()
    ts.run()

Result

start python server 0.0.0.0:18100

Success Response

{
    "code":1,
    "msg":"success",
    "data":"handle result data. AnyType"
}

Error Response

{
    "code":0,
    "msg":"error message",
    "data":{}
}

Client

from client import Client

with Client("127.0.0.1",18100) as c:
    result = c.test_function({"msg":"hello world"})
    print(type(result))
    print(result)

Result

<class 'str'>
{
 "code": 1,
 "msg": "success",
 "data": {
  "say": "Happy everyday!!!"
 }
}

Refs

Thrift

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transmit-0.1.0.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

transmit-0.1.0-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page