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

Commit e6f4328

Browse files
Merge pull request #203 from samuelhwilliams/app-start-arg
Allow a Bottle instance to be passed to Eel
2 parents a9e1db8 + af37984 commit e6f4328

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change log
22

3+
### v0.11.0 (not yet released)
4+
* Added support for `app` parameter to `eel.start`, which will override the bottle app instance used to run eel. This
5+
allows developers to apply any middleware they wish to before handing over to eel.
6+
37
### v0.10.4
48
* Fix PyPi project description.
59

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Additional options can be passed to `eel.start()` as keyword arguments.
8686

8787
Some of the options include the mode the app is in (e.g. 'chrome'), the port the app runs on, the host name of the app, and adding additional command line flags.
8888

89-
As of Eel 1.0.0, the following options are available to `start()`:
89+
As of Eel v0.11.0, the following options are available to `start()`:
9090
- **mode**, a string specifying what browser to use (e.g. `'chrome'`, `'electron'`, `'edge'`, `'custom'`). Can also be `None` or `False` to not open a window. *Default: `'chrome'`*
9191
- **host**, a string specifying what hostname to use for the Bottle server. *Default: `'localhost'`)*
9292
- **port**, an int specifying what port to use for the Bottle server. Use `0` for port to be picked automatically. *Default: `8000`*.
@@ -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)