Ali*_*464 5 html javascript python jquery
我正在学习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 src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
async function display_weather(){
let place = document.getElementById('location').value;
let res = await eel.get_weather(place)();
document.getElementById('info').innerHTML = res;
}
jQuery('#show').on('click', function(){
display_weather();
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是Python代码:
import eel
import pyowm
own = pyowm.OWM('d845c8640738fe82515cb1277bb3dd38')
@eel.expose
def get_weather(place):
mgr = own.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
temp = w.temperature('celsius')['temp']
return city + ' ' + str(temp)
#eel.init('web')
#eel.start('index.html', size=(700, 700))
Run Code Online (Sandbox Code Playgroud)
有人说我必须用这些文件上传 eel 文件,但是我应该从哪里获取该文件呢?有人说我应该下载,但是我已经通过cmd下载了。顺便说一句,我使用 Linux Mint 20。
| 归档时间: |
|
| 查看次数: |
210 次 |
| 最近记录: |