import eel
import pyowm
from pyowm.utils import config
from pyowm.utils import timestamps
from pyowm.utils.config import get_default_config
eel.init("web")
owm = pyowm.OWM("642981b66c58c03a9a0c155155779276")
config_dict = get_default_config()
config_dict['language'] = 'ru'
@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 + ' сейчас ' + w.detailed_status + ', ' +'на улице примерно ' + str(temp) + '°С' + '\n\n'
eel.start("main.html", size = (1000, 500))
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>weather</title>
<script type="text/javascript" src="eel.js"></script>
<link rel="stylesheet" href="main.css">
<link rel="icon" type="image/png" href="/icon.png">
</head>
<body id ="body1">
<h1 id = "hello"> WEATHER </h1>
<p id = "input1"><input id = "location" type = "text" required="" placeholder="Введите название страны или города"></p>
<p><button id = "show" type="submit"> Узнать погоду </button></p>
<div id = "info"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/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>
Компилированный файл .exe выдает ошибку:
Error: 404 Not Found
Sorry, the requested URL '
localhost:8000/main.html' caused an error:
File does not exist.