diff --git a/test-python-ssh/nginx/nginx.conf b/test-python-ssh/nginx/nginx.conf index 989c43f..457538a 100644 --- a/test-python-ssh/nginx/nginx.conf +++ b/test-python-ssh/nginx/nginx.conf @@ -30,17 +30,17 @@ server { listen 80; listen [::]:80; - root /usr/share/app/python_app/modules/; + root /app/python_app/modules/; location ~ favicon.ico { root /usr/share/app/; } location / { -# index index.html main.py; -# try_files $uri $uri/ =404; -# } + index index.html main.py; + try_files $uri $uri/ =404; + } - #location ~ \.py { + location ~ \.py { include uwsgi_params; #uwsgi_param PATH_INFO "$1"; #uwsgi_param SCRIPT_NAME /; diff --git a/test-python-ssh/python_app/main.py b/test-python-ssh/python_app/main.py index 1080b3d..89beded 100644 --- a/test-python-ssh/python_app/main.py +++ b/test-python-ssh/python_app/main.py @@ -29,14 +29,13 @@ def application(env, start_response): path = path_minus_one function = path_elements[-1] elif os.path.isfile(BASE_MODULE_PATH + path): + path = path_minus_one + '/main' function = 'index' elif os.path.isdir(BASE_MODULE_PATH + path): path += '/main' function = 'index' else: - return htmlresp(404, 'Le dossier {} n’a pas été trouvé.'.format(path), start_response) - - + return htmlresp(404, 'Le fichier ou dossier {} n’a pas été trouvé.'.format(path), start_response) # Module full path module_path = BASE_MODULE_PATH + path @@ -47,7 +46,7 @@ def application(env, start_response): m = importlib.import_module(module_path) importlib.reload(m) except ModuleNotFoundError: - #print('Le fichier {} n’a pas été trouvé. {}'.format(module_path, str(path_elements))) + print('Le fichier {} n’a pas été trouvé. {}'.format(module_path, str(path_elements))) return htmlresp(404, 'Le fichier {} n’a pas été trouvé.'.format(path), start_response) # Find which parameters the function needs