Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

Commit d053c1f

Browse files
Allow a Bottle instance to be passed to Eel
This will allow end users to create their own Bottle app and inject any middleware they want, e.g. to handle authentication or session management, before Eel takes over. Resolves #199
1 parent 7deccfd commit d053c1f

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ As of Eel 1.0.0, the following options are available to `start()`:
9797
- **position**, a tuple of ints specifying the (left, top) of the main window in pixels *Default: `None`*
9898
- **geometry**, a dictionary specifying the size and position for all windows. The keys should be the relative path of the page, and the values should be a dictionary of the form `{'size': (200, 100), 'position': (300, 50)}`. *Default: {}*
9999
- **close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`*
100+
- **app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the
101+
instance before starting eel, e.g. for session management, authentication, etc.
100102

101103

102104

eel/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
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
4344
}
4445

4546
# == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 ===
@@ -141,7 +142,8 @@ def run_lambda():
141142
host=HOST,
142143
port=_start_args['port'],
143144
server=wbs.GeventWebSocketServer,
144-
quiet=True)
145+
quiet=True,
146+
app=_start_args.get('app'))
145147

146148
# Start the webserver
147149
if _start_args['block']:

0 commit comments

Comments
 (0)