@@ -112,10 +112,6 @@ def __init__(self, config=None, args=None):
112
112
self ._app = FastAPI ()
113
113
self ._password = None
114
114
115
- # Change the default root path
116
- if self .url_prefix != '/' :
117
- self ._app .include_router (APIRouter (prefix = self .url_prefix .rstrip ('/' )))
118
-
119
115
# Set path for WebUI
120
116
webui_root_path = config .get_value (
121
117
'outputs' , 'webui_root_path' , default = os .path .dirname (os .path .realpath (__file__ ))
@@ -147,11 +143,15 @@ def __init__(self, config=None, args=None):
147
143
def load_config (self , config ):
148
144
"""Load the outputs section of the configuration file."""
149
145
# Limit the number of processes to display in the WebUI
150
- self .url_prefix = '/ '
146
+ self .url_prefix = ''
151
147
if config is not None and config .has_section ('outputs' ):
148
+ # Max process to display in the WebUI
152
149
n = config .get_value ('outputs' , 'max_processes_display' , default = None )
153
150
logger .debug (f'Number of processes to display in the WebUI: { n } ' )
154
- self .url_prefix = config .get_value ('outputs' , 'url_prefix' , default = '/' )
151
+ # URL prefix
152
+ self .url_prefix = config .get_value ('outputs' , 'url_prefix' , default = '' )
153
+ if self .url_prefix != '' :
154
+ self .url_prefix = self .url_prefix .rstrip ('/' )
155
155
logger .debug (f'URL prefix: { self .url_prefix } ' )
156
156
157
157
def __update__ (self ):
@@ -179,7 +179,8 @@ def authentication(self, creds: Annotated[HTTPBasicCredentials, Depends(security
179
179
180
180
def _router (self ):
181
181
"""Define a custom router for Glances path."""
182
- router = APIRouter ()
182
+ # Create une main router
183
+ router = APIRouter (prefix = self .url_prefix )
183
184
184
185
# REST API
185
186
router .add_api_route (
@@ -278,7 +279,7 @@ def _router(self):
278
279
router .add_api_route ('/' , response_class = HTMLResponse , endpoint = self ._index )
279
280
280
281
# Statics files
281
- self ._app .mount (" /static" , StaticFiles (directory = self .STATIC_PATH ), name = "static" )
282
+ self ._app .mount (urljoin ( self . url_prefix , ' /static' ) , StaticFiles (directory = self .STATIC_PATH ), name = "static" )
282
283
283
284
logger .info (f"Get WebUI in { self .STATIC_PATH } " )
284
285
0 commit comments