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.
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()
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)
Full Code:
main.py
Sample index.html