Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change log

### v0.11.1
* Fix the implementation of #203, allowing users to pass their own bottle instances into Eel.

### v0.11.0
* Added support for `app` parameter to `eel.start`, which will override the bottle app instance used to run eel. This
allows developers to apply any middleware they wish to before handing over to eel.
Expand Down
22 changes: 15 additions & 7 deletions eel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'app_mode': True, # (Chrome specific option)
'all_interfaces': False, # Allow bottle server to listen for connections on all interfaces
'disable_cache': True, # Sets the no-store response header when serving assets
'app': None, # Allows passing in a custom Bottle instance, e.g. with middleware
'app': btl.default_app(), # Allows passing in a custom Bottle instance, e.g. with middleware
}

# == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 ===
Expand Down Expand Up @@ -138,12 +138,18 @@ def run_lambda():
HOST = '0.0.0.0'
else:
HOST = _start_args['host']

app = _start_args['app'] # type: btl.Bottle
for route_path, route_params in BOTTLE_ROUTES.items():
route_func, route_kwargs = route_params
app.route(path=route_path, callback=route_func, **route_kwargs)

return btl.run(
host=HOST,
port=_start_args['port'],
server=wbs.GeventWebSocketServer,
quiet=True,
app=_start_args.get('app'))
app=app)

# Start the webserver
if _start_args['block']:
Expand All @@ -165,7 +171,6 @@ def spawn(function, *args, **kwargs):

# Bottle Routes

@btl.route('/eel.js')
def _eel():
start_geometry = {'default': {'size': _start_args['size'],
'position': _start_args['position']},
Expand All @@ -179,8 +184,6 @@ def _eel():
_set_response_headers(btl.response)
return page


@btl.route('/<path:path>')
def _static(path):
response = None
if 'jinja_env' in _start_args and 'jinja_templates' in _start_args:
Expand All @@ -196,8 +199,6 @@ def _static(path):
_set_response_headers(response)
return response


@btl.get('/eel', apply=[wbs.websocket])
def _websocket(ws):
global _websockets

Expand All @@ -223,6 +224,13 @@ def _websocket(ws):

_websocket_close(page)


BOTTLE_ROUTES = {
"/eel.js": (_eel, dict()),
"/<path:path>": (_static, dict()),
"/eel": (_websocket, dict(apply=[wbs.websocket]))
}

# Private functions

def _safe_json(obj):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='Eel',
version='0.11.0',
version='0.11.1',
author='Chris Knott',
author_email='[email protected]',
packages=['eel'],
Expand Down