I am trying to return a function from Python onto google chrome console using eel in Python.
This is the current code I have:
Python
import eel
eel.init('web')
print("Start")
@eel.expose
def my_python_function(a, b):
print(a, b)
eel.start('index.html')
HTML
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Tutorial</title>
<script type="text/javascript" src="/eel.js"></script>
<script>
console.log('Calling Python...');
eel.my_python_function(1, 2);
</script>
</head>
<body>
<p>test</p>
</body>
</html>
In the HTML js script, eel.my_python_function(1,2) will print out onto the cmd.
I have tried the following to try get the Python function to be outputted onto the Chrome console.
Take 1
<script type="text/javascript" src="/eel.js"></script>
<script>
console.log('Calling Python...');
a = eel.my_python_function(1, 2);
console.log(a);
</script>
this gave me this output on google chrome:
ƒ (callback = null) {
if(callback != null) {
eel._call_return_callbacks[call.call] = callback;
} else {
return new Promise(function(resolve) {
and this is my Try 2
<script type="text/javascript" src="/eel.js"></script>
<script>
console.log('Calling Python...');
a = eel.my_python_function(1, 2);
console.log(a());
</script>
Have adjusted the console.log(a); to console.log(a());
The output was promise
The real output should be 1 2