diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-08-08 21:33:52 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-08-08 21:33:52 +0300 |
commit | dc0b15149152f64ee9eeec3fd1870df9fee83a86 (patch) | |
tree | f9aa54268a98f34a9501f46f93245458bbe9d646 | |
parent | dbc9e6b36b84a83722cb641f6bf668412b6a8180 (diff) |
-rwxr-xr-x | msshpd | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -7,6 +7,7 @@ from argparse import ArgumentParser routes = web.RouteTableDef() mss_host = None mss_port = None +mss_json_response = False class MySimpleSocketClient: @@ -41,7 +42,11 @@ async def variable_handler(request): client.write(command) try: - response = {'data': client.read()} + raw = client.read() + if mss_json_response: + response = json.loads(raw) + else: + response = {'data': raw} except Exception as e: response = {'error': str(e)} @@ -52,12 +57,14 @@ if __name__ == '__main__': parser = ArgumentParser() parser.add_argument('--mss-host', required=True, type=str) parser.add_argument('--mss-port', required=True, type=int) + parser.add_argument('--mss-json-response', action='store_true') parser.add_argument('--host', default='0.0.0.0', type=str) parser.add_argument('--port', default=8080, type=int) args = parser.parse_args() mss_host = args.mss_host mss_port = args.mss_port + mss_json_response = args.mss_json_response logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) |