@@ -147,6 +147,7 @@ class Teleop:
147147 Args:
148148 host (str, optional): The host IP address. Defaults to "0.0.0.0".
149149 port (int, optional): The port number. Defaults to 4443.
150+ frontend_dir (str, optional): The directory containing the frontend assets. Defaults to THIS_DIR.
150151 """
151152
152153 def __init__ (
@@ -155,6 +156,7 @@ def __init__(
155156 port = 4443 ,
156157 natural_phone_orientation_euler = None ,
157158 natural_phone_position = None ,
159+ frontend_dir = None ,
158160 ):
159161 self .__logger = logging .getLogger ("teleop" )
160162 self .__logger .setLevel (logging .INFO )
@@ -179,6 +181,10 @@ def __init__(
179181 [1 , 1 , 1 ],
180182 )
181183
184+ if frontend_dir is None :
185+ frontend_dir = THIS_DIR
186+ self .__frontend_dir = frontend_dir
187+
182188 self .__app = FastAPI ()
183189 self .__manager = ConnectionManager ()
184190
@@ -280,13 +286,13 @@ def __update(self, message):
280286
281287 def __setup_routes (self ):
282288 # Mount static files directory
283- assets_dir = os .path .join (THIS_DIR , "assets" )
289+ assets_dir = os .path .join (self . __frontend_dir , "assets" )
284290 self .__app .mount ("/assets" , StaticFiles (directory = assets_dir ), name = "assets" )
285291
286292 @self .__app .get ("/" )
287293 async def index ():
288294 self .__logger .debug ("Serving the index.html file" )
289- return FileResponse (os .path .join (THIS_DIR , "index.html" ))
295+ return FileResponse (os .path .join (self . __frontend_dir , "index.html" ))
290296
291297 @self .__app .websocket ("/ws" )
292298 async def websocket_endpoint (websocket : WebSocket ):
0 commit comments