A small socket gateway server. A simple socket client for sending json
Project description
Gateway Server or Client
This is client and server code for a gateway between internal and external network. That's to provide a way to communicate between the inside and the outside of network environment.
Usage
Rceive http request with json -> send json and get response in json.
With client you can send json to response to an http request.
Example
Client
Send a request
# Exemple of use
if __name__ == "__main__":
client = WebSocketClient("ws://127.0.0.1:4200/ws", simple=True)
client.run()
try:
# send what you want
# client.send({"test": "test"})
time.sleep(60)
except KeyboardInterrupt:
client.close()
except Exception as e:
print(f"An error occurred: {e}")
Get a response
You should override the process_message method from WebSocketClient class.
class WebSocketClient(WebSocketBaseClient):
def process_message(self, message):
print(f"Received: {message}")
# or
client = WebSocketClient("ws://127.0.0.1", simple=True)
client.run()
# send what you want
# client.send({"test": "test"})
client.close()
simple parameter is used to send json without modification to match with the gateway server.
With simple parameter you can send json to any other server.
Gateway
TODO
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
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 httpsocketgateway-0.2.6.tar.gz.
File metadata
- Download URL: httpsocketgateway-0.2.6.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a1f1aacf5a31832f11db50fbd22da1e7990d39c87e2ff83a0cc092a0f9843d3
|
|
| MD5 |
bf32726a83cf63cebf9a2e5d76f03ada
|
|
| BLAKE2b-256 |
2ea69646c0b3ddf0a401b37dd4a85cf7f088d207a062349bf0451a301f4b6f6b
|
File details
Details for the file httpsocketgateway-0.2.6-py3-none-any.whl.
File metadata
- Download URL: httpsocketgateway-0.2.6-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcdc885cea2d87118308c6564c6ec6d2ccaa996c37f0f1d58ecc3884a12f3602
|
|
| MD5 |
35d84f07b968df42040df1a758380e77
|
|
| BLAKE2b-256 |
7cd8e9223d0ef3684092e0adb4f321f2c7d60f586afd19f2f2604a58268a05b9
|