F
F
fazzxne2021-06-05 19:42:47
Python
fazzxne, 2021-06-05 19:42:47

Why is there an error on the site when using eel?

60bbaf69de9be265159655.jpega number is entered in the first line of the site, after pressing the button, a python function is used that adds one to the number from the first line, after this the result should be in the second line, but as a result, this is displayed in the second line: function(callback = null) { if( callback != null) { eel._call_return_callbacks[call.call] = {resolve: callback}; } else { return new Promise(function(resolve, reject) { eel._call_return_callbacks[call.call] = {resolve: resolve, reject: reject}; }); } }

python code:

import eel
eel.init('web')
@eel.expose
def my_python_function(a):
    a+=1
    print(a)
eel.start('main.html',size=(500,500))


html:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="/eel.js"></script>
    <title>Document</title>
</head>
<body>
    <script>
        async function random(){
            let a = document.getElementById("ww").value;
            a=Number(a);
            let b = await eel.my_python_function(a);
            document.getElementById("ee").value=b;
        }
    </script>
    <input id="ww" type="text">
    <button onclick="random()">otp</button>
    <input id="ee" type="text">
</body>
</html>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-06-05
@fazzxne

1. Functions are used differently.
https://github.com/ChrisKnott/Eel#return-values ​​2. For a function to return a value, you need to add , which is logical
let b = await eel.my_python_function(a)();

def my_python_function(a):
    a+=1
    return a

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question