4040 'app_mode' : True , # (Chrome specific option)
4141 'all_interfaces' : False , # Allow bottle server to listen for connections on all interfaces
4242 'disable_cache' : True , # Sets the no-store response header when serving assets
43- 'app' : None , # Allows passing in a custom Bottle instance, e.g. with middleware
43+ 'app' : btl . default_app (), # Allows passing in a custom Bottle instance, e.g. with middleware
4444}
4545
4646# == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 ===
@@ -138,12 +138,18 @@ def run_lambda():
138138 HOST = '0.0.0.0'
139139 else :
140140 HOST = _start_args ['host' ]
141+
142+ app = _start_args ['app' ] # type: btl.Bottle
143+ for route_path , route_params in BOTTLE_ROUTES .items ():
144+ route_func , route_kwargs = route_params
145+ app .route (path = route_path , callback = route_func , ** route_kwargs )
146+
141147 return btl .run (
142148 host = HOST ,
143149 port = _start_args ['port' ],
144150 server = wbs .GeventWebSocketServer ,
145151 quiet = True ,
146- app = _start_args . get ( ' app' ) )
152+ app = app )
147153
148154 # Start the webserver
149155 if _start_args ['block' ]:
@@ -165,7 +171,6 @@ def spawn(function, *args, **kwargs):
165171
166172# Bottle Routes
167173
168- @btl .route ('/eel.js' )
169174def _eel ():
170175 start_geometry = {'default' : {'size' : _start_args ['size' ],
171176 'position' : _start_args ['position' ]},
@@ -179,8 +184,6 @@ def _eel():
179184 _set_response_headers (btl .response )
180185 return page
181186
182-
183- @btl .route ('/<path:path>' )
184187def _static (path ):
185188 response = None
186189 if 'jinja_env' in _start_args and 'jinja_templates' in _start_args :
@@ -196,8 +199,6 @@ def _static(path):
196199 _set_response_headers (response )
197200 return response
198201
199-
200- @btl .get ('/eel' , apply = [wbs .websocket ])
201202def _websocket (ws ):
202203 global _websockets
203204
@@ -223,6 +224,13 @@ def _websocket(ws):
223224
224225 _websocket_close (page )
225226
227+
228+ BOTTLE_ROUTES = {
229+ "/eel.js" : (_eel , dict ()),
230+ "/<path:path>" : (_static , dict ()),
231+ "/eel" : (_websocket , dict (apply = [wbs .websocket ]))
232+ }
233+
226234# Private functions
227235
228236def _safe_json (obj ):
0 commit comments