D
D
Depressedsai2021-11-27 19:40:03
Python
Depressedsai, 2021-11-27 19:40:03

HTML does not see the function call from Python. Why?

On the advice of soremix - thanks to him - I fixed some bugs in the developer tools. But I faced such error.

async function display_weather() {
          url: "~/main.py";
          let place = document.getElementById('location').value;
          let res = await eel.get_weather(place)(); 
          document.getElementById('info').innetHTML = res;
        }
    
        jQuery('#show').on('click', function() {
          display_weather();
        });


I have this async function in html code. But when I hit F12 on the page, there is an error line: main.html:27 Uncaught (in promise) ReferenceError: eel is not defined

Why doesn't HTML see the functions, namely the "eel" part?

Here is the code from the Python file:

import eel
import pyowm

eel.init("web")
eel.start("main.html", size=(1000, 800))

owm = pyowm.OWM("87c22185adb4fbaf72d55722562bc9ca")

@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) + " градусов!"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question