gatenet.http_ package¶
Submodules¶
gatenet.http_.async_client module¶
- class gatenet.http_.async_client.AsyncHTTPClient(base_url)[source]¶
Bases:
objectAsynchronous HTTP client for making requests using aiohttp.
Supports GET, POST, PUT, PATCH, and DELETE methods via async/await.
Example
>>> import asyncio >>> from gatenet.http_.async_client import AsyncHTTPClient >>> async def main(): ... client = AsyncHTTPClient("http://127.0.0.1:8000") ... resp = await client.get("/status") ... print(resp) >>> asyncio.run(main()) {'ok': True, 'status': 200, 'data': {'ok': True}, 'error': None}
gatenet.http_.base module¶
- class gatenet.http_.base.SimpleHTTPRequestHandler(request, client_address, server)[source]¶
Bases:
BaseHTTPRequestHandlerBasic HTTP request handler that responds to GET requests with a plain text message.
Example
>>> from gatenet.http_.base import SimpleHTTPRequestHandler >>> # Use with Python's HTTPServer for custom GET handling
gatenet.http_.client module¶
- class gatenet.http_.client.HTTPClient(base_url)[source]¶
Bases:
objectLightweight HTTP client for making requests using Python’s built-in urllib.
Supports GET, POST, PUT, PATCH, and DELETE methods via method chaining.
Example
>>> from gatenet.http_.client import HTTPClient >>> client = HTTPClient("http://127.0.0.1:8000") >>> response = client.get("/status") >>> print(response) {'ok': True, 'status': 200, 'data': {'ok': True}, 'error': None}
gatenet.http_.server module¶
- class gatenet.http_.server.HTTPServerComponent(host='127.0.0.1', port=8000, hooks=None)[source]¶
Bases:
objectSimple HTTP server component for serving JSON responses.
Binds to the given host and port.
Uses Python’s built-in HTTP server.
Runs in a background thread via start().
Supports dynamic route registration via the route decorator.
Example
>>> from gatenet.http_.server import HTTPServerComponent >>> server = HTTPServerComponent(host="127.0.0.1", port=8080) >>> @server.route("/status", method="GET") ... def status_handler(req): ... return {"ok": True} >>> server.start() # Now visit http://127.0.0.1:8080/status
Module contents¶
- class gatenet.http_.AsyncHTTPClient(base_url)[source]¶
Bases:
objectAsynchronous HTTP client for making requests using aiohttp.
Supports GET, POST, PUT, PATCH, and DELETE methods via async/await.
Example
>>> import asyncio >>> from gatenet.http_.async_client import AsyncHTTPClient >>> async def main(): ... client = AsyncHTTPClient("http://127.0.0.1:8000") ... resp = await client.get("/status") ... print(resp) >>> asyncio.run(main()) {'ok': True, 'status': 200, 'data': {'ok': True}, 'error': None}
- class gatenet.http_.HTTPClient(base_url)[source]¶
Bases:
objectLightweight HTTP client for making requests using Python’s built-in urllib.
Supports GET, POST, PUT, PATCH, and DELETE methods via method chaining.
Example
>>> from gatenet.http_.client import HTTPClient >>> client = HTTPClient("http://127.0.0.1:8000") >>> response = client.get("/status") >>> print(response) {'ok': True, 'status': 200, 'data': {'ok': True}, 'error': None}
- class gatenet.http_.HTTPServerComponent(host='127.0.0.1', port=8000, hooks=None)[source]¶
Bases:
objectSimple HTTP server component for serving JSON responses.
Binds to the given host and port.
Uses Python’s built-in HTTP server.
Runs in a background thread via start().
Supports dynamic route registration via the route decorator.
Example
>>> from gatenet.http_.server import HTTPServerComponent >>> server = HTTPServerComponent(host="127.0.0.1", port=8080) >>> @server.route("/status", method="GET") ... def status_handler(req): ... return {"ok": True} >>> server.start() # Now visit http://127.0.0.1:8080/status
- class gatenet.http_.SimpleHTTPRequestHandler(request, client_address, server)[source]¶
Bases:
BaseHTTPRequestHandlerBasic HTTP request handler that responds to GET requests with a plain text message.
Example
>>> from gatenet.http_.base import SimpleHTTPRequestHandler >>> # Use with Python's HTTPServer for custom GET handling