InnerHTML make python terminal error and don't work
Eel version 0.14.0
Describe the bug I expose my javascript function to my python, I run it, I pass 3 variable in parameter and when the function starts "document.getElementById ('port_open'). innerHTML = '
To Reproduce Steps to reproduce the behavior:
- index.js :
eel.expose(add_open_port); // Expose this function to Python function add_open_port(port, ip, time) { document.getElementById('port_open').innerHTML = '<div>' + ip + '</div>'; }
- main.py :
eel.add_open_port(str(i), str(ip), str(tt))
Expected behavior
Traceback (most recent call last): File "src\\gevent\\greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run File "C:\Users\Lylian\PycharmProjects\NetworkSniffer\venv\lib\site-packages\eel\__init__.py", line 303, in _process_message _call_return_values[call_id] = message['value'] KeyError: 'value' 2021-04-03T08:50:25Z <Greenlet at 0x1d8aa6df370: _process_message({'return': 2.427997873202775, 'status': 'error', ', <geventwebsocket.websocket.WebSocket object at 0x0)> failed with KeyError
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: WINDOWS
- Browser CHROME
- Version idk
If anyone has a similar issue, what solved it for me was making sure that no empty strings are passed to the JavaScript functions.
same
I too had this error and it actually made my life like hell. For anyone who lands on this page with the same problem, in my opinion, what causes this error is an exception raised by the JavaScript function called by Eel. This causes the message dict not to contain the key "value" that eel tries to access and hence causes this error.
Make sure that the JavaScript function you're trying to call via Eel does not have any error and there's no chance for it to raise an exception.
For debugging purposes, here's a tip for ya:
Open <PythonFolder>/Lib/site-packages/eel/init.py file and go to line 303, where there should be a code something like this:
_call_return_values[call_id] = message['value']
Change it to:
try: _call_return_values[call_id] = message['value'] except: print(message)
This will return the dict passed to Eel which also contains the error raised by the JavaScript function. You can use this to identify and fix the error easily.
Hope this helps.