You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Is your feature request related to a problem? Please describe.
I am trying to get session management in eel. Since eel uses bottle, I found this link that uses beaker module to set up a session. But it requires an app instance to be passed to bottle.run() method (which eel internally calls) but as of now there is no way to pass that to eel
Describe the solution you'd like
Allowing eel.start() to accept a 'app' option by adding the following in int.py
eel init.py (Changes)
btl_app=options.pop('app', None)
defrun_lambda():
returnbtl.run(
host=options['host'],
port=options['port'],
server=wbs.GeventWebSocketServer,
quiet=True,
app=btl_app) # Passing the app instance from options
Full Code:
main.py
"""Entry Point to The App"""importloggingimportosimportsysfromtkinterimportTk, messageboximporteelimportbottlefrombottleimportrequestimportbeaker.middlewareimporttimedefshow_error(title, msg):
root=Tk()
root.withdraw() # hide main windowmessagebox.showerror(title, msg)
root.destroy()
@eel.exposedefincrement_num():
print("HERE")
session=request.environ['beaker.session']
session['num'] =session.get('num', 0) +1print(session['num'])
time.sleep(1)
eel.call_py()() # Calling caller (js function)defstart_app():
# Start the servertry:
BASEDIR=os.path.dirname(os.path.abspath(__file__))
web_dir=BASEDIRstart_html_page='index.html'eel.init(web_dir)
logging.info("App Started")
session_opts= {
'session.type': 'file',
'session.data_dir': './session/',
'session.auto': True,
}
app=beaker.middleware.SessionMiddleware(bottle.app(), session_opts)
options= {'host': 'localhost', 'port': 0, 'app': app} # Need to provide a btl app to eeleel.start(start_html_page, options=options)
exceptExceptionase:
err_msg='Could not launch a local server'logging.error('{}\n{}'.format(err_msg, e.args))
show_error(title='Failed to initialise server', msg=err_msg)
logging.info('Closing App')
sys.exit()
if__name__=="__main__":
start_app()
Sorry for the delay in responding to this. While this does expose Bottle as part of the public interface (whereas it's currently an implementation detail) I think this is a pretty valuable proposal.
I'll add it for a v0.11.0 release and perhaps include it in a future v1.0.0-a2 release. This means that, should there be some negative consequences that I haven't thought of yet, it could be removed for an official v1.0.0 release - just FYI.
Hi, I was just trying to pass a beaker middleware (as shown in code above) but got the following error:
Traceback (most recent call last):
File "//run.py", line 52, in start_app
eel.start(start_html_page, mode='chrome', port=0, app=app)
File "//venv/lib/python3.6/site-packages/eel/init.py", line 161, in start
run_lambda()
File "//venv/lib/python3.6/site-packages/eel/init.py", line 151, in run_lambda
app.route(path=route_path, callback=route_func, **route_kwargs)
AttributeError: 'SessionMiddleware' object has no attribute 'route'
Activity
samuelhwilliams commentedon Oct 21, 2019
Sorry for the delay in responding to this. While this does expose Bottle as part of the public interface (whereas it's currently an implementation detail) I think this is a pretty valuable proposal.
I'll add it for a v0.11.0 release and perhaps include it in a future v1.0.0-a2 release. This means that, should there be some negative consequences that I haven't thought of yet, it could be removed for an official v1.0.0 release - just FYI.
Allow a Bottle instance to be passed to Eel
RahulBadenkal commentedon Jan 3, 2020
Hi, I was just trying to pass a beaker middleware (as shown in code above) but got the following error: