Transmit Server & Client use thrift
Project description
Transmit Server & Client
Install
pip install transmit
Usage
Server
from transmit.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 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":null
}
Client
from transmit.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 'dict'>
> {'say': 'Happy everyday!!!'}
Advanced Usage
- debug mode
debug mode will print and log all request and response data.
# debug server
> python test_server.py --debug 1
# debug client
with Client("127.0.0.1",18100,debug=True) as c:
...
- server cli setting
> python test_server.py --host="127.0.0.1" --port=3000 --workers=3 --debug=1
Refs
Project details
Release history Release notifications | RSS feed
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.4.0.tar.gz
(7.4 kB
view details)
Built Distribution
File details
Details for the file transmit-0.4.0.tar.gz
.
File metadata
- Download URL: transmit-0.4.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d41d1b7c5d7f3e4d6b6aeca268b1cde145885e75e5a47ff7b3a99f54dd9bcc17 |
|
MD5 | fbd6add34443a44b482fe359a217ec3f |
|
BLAKE2b-256 | 05e249dbae15e232bc49fbf44bb8cfc583f1cd9b90dfe5e39fee8ab88ade49d7 |
File details
Details for the file transmit-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: transmit-0.4.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3aa4387d6cefee029b75d3c90fc265e60f3294a8befe2c3515e3658624e084 |
|
MD5 | 44e7bb2993a62c1e67636c2da451df5b |
|
BLAKE2b-256 | 7abfbd96b8df2a84289377eff9887e7126827040b646405d5390438ec624bda7 |