Skip to main content

Python library for gateways, networks, and devices.

Project description

gatenet 🛰️

BETA (0.1.2)

Changelog

Package PyPI
Python Python
Tests CI codecov
License License

Python networking toolkit for sockets, UDP, and HTTP microservices — modular and testable.


Installation

pip install gatenet

Features

  • TCP for raw socket data
  • UDP
  • HTTP
    • Route-based handling
    • JSON responses
    • Dynamic request handling
    • Custom headers
    • Error handling
    • Timeout handling
  • 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.server 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


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.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gatenet-0.1.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file gatenet-0.1.2.tar.gz.

File metadata

  • Download URL: gatenet-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for gatenet-0.1.2.tar.gz
Algorithm Hash digest
SHA256 88c7f0e29a3b5626bd8e27b7bfc8724829d5c6faabf1ce2e7b9e0563e55951ba
MD5 a2db82c8a8f5e85096748fb588cefb5a
BLAKE2b-256 7e8f29b3ca02c4f9d0a2126da4221f284e4919a8b20a2a54fe1c5559087df0c7

See more details on using hashes here.

File details

Details for the file gatenet-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gatenet-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for gatenet-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a603ff2234775a0144c4f525cb83056d7440841ace000ec493b9716b35939c5
MD5 af7bd03c21f971e368ae1d7743120549
BLAKE2b-256 2dcc8ed065ec569ba1c935607ff4caed0b30ff09d59db7436c68a1eb45e0e6b7

See more details on using hashes here.

Supported by

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