diff options
Diffstat (limited to 'msshpd')
-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) |