5
5
6
6
from app .api import api
7
7
8
- def renderError (msg , error_header = "An error occured!" , statusCode = 500 ):
8
+ def render_error (msg , error_header = "An error occured!" , statusCode = 500 ):
9
9
return flask .render_template ('error.html' , error_header = error_header , error_message = msg ), statusCode
10
10
11
- def getValidSubpath (f : str , d : str ):
11
+ def get_valid_subpath (f : str , d : str ):
12
12
"""
13
13
Returns the absolute path of wanted file or directory, but only if it is contained in the given directory.
14
14
@@ -44,9 +44,9 @@ def get_config(name: str):
44
44
"""
45
45
nginx_path = flask .current_app .config ['NGINX_PATH' ]
46
46
47
- path = getValidSubpath (os .path .join (nginx_path , name ), nginx_path )
47
+ path = get_valid_subpath (os .path .join (nginx_path , name ), nginx_path )
48
48
if path == None :
49
- return renderError (f'Could not read file "{ path } ".' )
49
+ return render_error (f'Could not read file "{ path } ".' )
50
50
51
51
with io .open (path , 'r' ) as f :
52
52
_file = f .read ()
@@ -70,7 +70,7 @@ def post_config(name: str):
70
70
71
71
config_file = os .path .join (nginx_path , name )
72
72
73
- path = getValidSubpath (config_file , nginx_path )
73
+ path = get_valid_subpath (config_file , nginx_path )
74
74
if path == None :
75
75
return flask .make_response ({'success' : False }), 500
76
76
@@ -94,7 +94,7 @@ def get_domains():
94
94
95
95
if not os .path .exists (config_path ):
96
96
error_message = f'The config folder "{ config_path } " does not exists.'
97
- return renderError (error_message )
97
+ return render_error (error_message )
98
98
for _ in os .listdir (config_path ):
99
99
100
100
if os .path .isfile (os .path .join (config_path , _ )):
@@ -168,7 +168,7 @@ def post_domain(name: str):
168
168
new_domain = flask .render_template ('new_domain.j2' , name = name )
169
169
name = name + '.conf.disabled'
170
170
171
- path = getValidSubpath (os .path .join (config_path , name ), config_path )
171
+ path = get_valid_subpath (os .path .join (config_path , name ), config_path )
172
172
if path == None :
173
173
return flask .jsonify ({'success' : False , 'error_msg' : 'invalid domain path' }), 500
174
174
0 commit comments