Python library for gateways, networks, and devices.
Project description
gatenet 🛰️
BETA (0.1.0)
Python networking toolkit for sockets, UDP, and HTTP microservices — modular and testable.
Installation
pip install gatenet
Features
- TCP Server for raw socket data
- UDP Server & Client
- HTTP Server
- Route-based handling
- JSON responses
- POST support
- Minimal, composable, Pythonic design
TCP Server
from gatenet.socket.tcp import TCPServer
server = TCPServer(host='127.0.0.1', port=8000)
@server.on_receive
def handle_data(data, addr):
print(f"[TCP] {addr} sent: {data}")
return f"Echo: {data}"
server.start()
UDP Server & Client
UDP Server
from gatenet.socket.udp import UDPServer
server = UDPServer(host="127.0.0.1", port=9000)
@server.on_receive
def handle_udp(data, addr):
print(f"[UDP] {addr} sent: {data}")
return f"Got your message: {data}"
server.start()
UDP Client
from gatenet.socket.udp import UDPClient
client = UDPClient(host="127.0.0.1", port=9000)
response = client.send("Hello, UDP!")
print(response)
HTTP Server & Client
HTTP Server
from gatenet.http.base import HTTPServerComponent
server = HTTPServerComponent(host="127.0.0.1", port=8080)
@server.route("/status", method="GET")
def status(_req):
return {
"ok": True
}
@server.route("/echo", method="POST")
def echo(_req, data):
return {
"received": data
}
server.start()
HTTP Client
from gatenet.http.client import HTTPClient
client = HTTPClient("http://127.0.0.1:8080")
print(client.get("/status")) # {"ok": True}
print(client.post("/echo", {"x": 1})) # {"received": {"x": 1}}
Tests
pytest
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
gatenet-0.1.1.tar.gz
(5.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gatenet-0.1.1.tar.gz.
File metadata
- Download URL: gatenet-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6692980594361946d93226a6c6fbe86d06481dfb9ebbd714b0ec0613d764b5b1
|
|
| MD5 |
958988b55ea409957afd0398c17253e4
|
|
| BLAKE2b-256 |
ea6b1323e4a1e36a6e13835fdecfb24a8f6a126e54ed85e002c4567759332fa8
|
File details
Details for the file gatenet-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gatenet-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9173e7e99bce47518186c3276192f43661d2e1cca720779b529d4704824ee73
|
|
| MD5 |
80b53448517f68cc931f8626fc3c8a69
|
|
| BLAKE2b-256 |
98a22dca95268a3925e80198979223c540e661c952067a676f07f42ee346c7b7
|