-1

I'm doing a project, I need to print a weather forecast, it doesn't seem to give out an error code, but the page is empty. Nothing is output your text

<!DOCTYPE html>
<html>
    <head>
        <script defer src="https://pyscript.net/releases/2022.12.1/pyscript.js"></script>
        <link rel="stylesheet" href="https://pyscript.net/releases/2022.12.1/pyscript.css"/>
    </head>
    <body>
        <py-script>
            import pyodide
            import asyncio
            API_KEY = '8e4cf478-53b6-45bc-8597-9946db9f1fd5'
            url = 'https://api.weather.yandex.ru/v2/forecast'
            params = {
                'lat': 55.753215,
                'lon': 37.622504,
                'lang': 'ru_RU'
            }
            headers = {
                'X-Yandex-API-Key': API_KEY
            }

            async def get_weather():
                response = await pyodide.fetch(url=url, params=params, headers=headers, method="GET")
                response_dict = await response.json()
                data = response.json()
                fact = data.get('fact')
                temperature = fact.get('temp')
                print(f'Погода в Москве: {temperature} градусов по Цельсию')

            asyncio.ensure_future(get_weather())
        </py-script>
    </body>
</html>
2
  • What if you remove apostle </html>```? Commented Dec 27, 2023 at 14:59
  • 1
    Accidentally wrote Commented Dec 27, 2023 at 15:06

1 Answer 1

1

In PyScript 2023.11.1 and newer, print only routes to the browser's developer console. Use PyScript's display() function to send content to the page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.