我正在学习Python和JS。我尝试编写一个显示天气的应用程序。但我收到了这个错误:
Failed to load resource: net::ERR_FILE_NOT_FOUND
main.html:27 Uncaught (in promise) ReferenceError: eel is not defined
at display_weather (main.html:27)
at HTMLButtonElement.<anonymous> (main.html:32)
at HTMLButtonElement.dispatch (jquery.min.js:2)
at HTMLButtonElement.v.handle (jquery.min.js:2)
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多东西来解决这个问题,但我不能。eel 有问题,我已经安装了教程中显示的 eel。这是带有 html 和 js 的文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Weather by Alibek</title>
<script type="text/javascript" src="/eel.js"></script>
<link rel="stylesheet" type="image/png" href="weather-icon.png">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<input id="location" type="text" placeholder="Write the name of your Country ot City" required="" value="Bukhara, Uzbekistan">
<button id ="show">Know the weather</button>
<div id="info ">
</div>
<script …Run Code Online (Sandbox Code Playgroud)
Everythink 进展顺利,但是当我完成代码并尝试运行时,我收到了此错误,您认为会发生什么。我使用 Linux Mint。我认为问题出在 EEL 模块上,当我运行 html 代码并转到控制台时,我可以看到GET file:///eel.js net::ERR_FILE_NOT_FOUND
我已经解决这个问题 3-4 天了,但我找不到答案。我希望你能帮助我解决这个问题。Python代码:
import eel
import pyowm
own = pyowm.OWM('d845c8640738fe82515cb1277bb3dd38')
eel.init('web')
eel.start('main.html', size=(700, 700))
@eel.expose
def get_weather(city):
mgr = own.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
temp = w.temperature('celsius')['temp']
return city + ' ' + str(temp)
Run Code Online (Sandbox Code Playgroud)
和 html/js 代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Weather</title>
<script type="text/javascript" src="/eel.js"></script>
<link rel="stylesheet" type="image/png" href="weather-icon.png">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<input id="location" type="text" placeholder="Write the name of your Country ot …Run Code Online (Sandbox Code Playgroud)