Answer the question
In order to leave comments, you need to log in
Not outputting weather, weather python code using eel and pyowm libraries?
import eel
import pyowm
owm = pyowm.OWM("8a1e96eb0d666fb9f233965c636924bf")
@eel.expose
def get_weather(place):
mgr = owm.weather_manager()
observation = mgr.weather_at_place(place)
w = observation.weather
temp = w.temperature('celsius')['temp']
return "В городе " + place + "сейчас " + str(temp) + " градусов."
eel.init("web")
eel.start("main.html", size=(700 , 700))
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Погода</title>
<script src="eel.js"></script>
<link rel="icon" type="image/png" href="/favicon.png">
<link rel="stylesheet" type="text/css" href="main.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:[email protected]&display=swap" rel="stylesheet">
</head>
<body>
<input id="location" type="text" placeholder="Введите название: Город, Страна..." required="" >
<button id="show">Нажать</button>
<div class="info"></div>
<script src="https://ajax.googleapis.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>
Answer the question
In order to leave comments, you need to log in
Press F12, open the console, you have all the errors written there.
On versions below 3 there is no manager. What do you have?
"AttributeError("'OWM25' object has no attribute 'weather_manager'",)"
<div class="info"></div>
<div id="info"></div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question