21
loading...
This website collects cookies to deliver better user experience
pip install zeroapi
zero
package is already there 🙁server.py
from zero import ZeroServer
def echo(msg: str):
return msg
async def hello_world():
return "hello world"
if __name__ == "__main__":
app = ZeroServer(port=5559)
app.register_rpc(echo)
app.register_rpc(hello_world)
app.run()
python -m server
from zero import ZeroClient
zero_client = ZeroClient("localhost", 5559)
def echo():
resp = zero_client.call("echo", "Hi there!")
print(resp)
def hello():
resp = zero_client.call("hello_world", None)
print(resp)
if __name__ == "__main__":
echo()
hello()
Inter-service communication is faster as using ZeroMQ and raw TCP under the hood.
Simple and easy to learn and use.
Extremely lightweight.
Super flexible zero can be used only for network communication and you can structure your codebase independently.
Not an HTTP framework, not so much traditional like Flask of FastAPI. People need to understand the actual usage. Like if you have fairly large microservice architecture and there are independent services that communicate among them, zero is a good substitute to reduce network overhead and other framework complexity. But if you only have a few services that communicate directly with the client/frontend, zero is not that much of a use.
Only Python based framework. Zero server can only be connected with Python zero client for now. (I have plan to introduce Go, in distant future btw)
You always need another HTTP framework as a gateway if your frontend communicates over HTTP, which is the usual and extremely common way.