From e3e7b7b5f7beccd817c6d223fddfcb126075f07d Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Mon, 15 Feb 2021 10:43:25 +0100 Subject: [PATCH] custom status possible --- test-python-ssh/python_app/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test-python-ssh/python_app/main.py b/test-python-ssh/python_app/main.py index 01b200a..013a3b7 100644 --- a/test-python-ssh/python_app/main.py +++ b/test-python-ssh/python_app/main.py @@ -72,7 +72,11 @@ def application(env, start_response): return htmlresp(400, 'La fonction {} demande les arguments suivants : {}. On a uniquement {}.'.format(function, params, ), start_response) try: - return htmlresp(200, str(f(**params)), start_response, False) + response = f(**params) + if type(response) is tuple: + return htmlresp(response[0], str(response[1]), start_response, False) + else: + return htmlresp(200, str(response), start_response, False) except Exception: return htmlresp(400, 'Erreur à l’exécution de la fonction {}.'.format(function), start_response)