Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript使用Python函数和eel_Javascript_Python_Eel - Fatal编程技术网

Javascript使用Python函数和eel

Javascript使用Python函数和eel,javascript,python,eel,Javascript,Python,Eel,我正在用Python和JavaScript制作一个聊天机器人程序。我使用eel为chatbot创建UI,但python代码中公开的函数不能用于JavaScript代码 Python代码 @eel.expose def responsedMessage(message): word = tokenize(message) if not word == '@': reply = load_w2v(word) else: reply = ''

我正在用Python和JavaScript制作一个聊天机器人程序。我使用eel为chatbot创建UI,但python代码中公开的函数不能用于JavaScript代码

Python代码

@eel.expose
def responsedMessage(message):
    word = tokenize(message)
    if not word == '@':
        reply = load_w2v(word)
    else:
        reply = ''
    response = make_sentence(reply)
    return response
JavaScript

async function btnFunc(){
    if(!inputText.value) return false;
    output(inputText.value,'me');
    const response = await eel.responsedMessage(inputText.value);
    output(response,'robot');
}
错误

chatbot_js.html:60 Uncaught (in promise) TypeError: eel.responsedMessage is not a function
at btnFunc (chatbot_js.html:60)
at HTMLInputElement.onclick (chatbot_js.html:16)

为什么会发生此错误?

您应该将eel.start('main.html')放在python脚本的末尾

@eel.expose
def responsedMessage(message):
    word = tokenize(message)
    if not word == '@':
        reply = load_w2v(word)
    else:
        reply = ''
    response = make_sentence(reply)
    return response

eel.start('main.html')