Download static/python/weather_api.py from AstraOS/pyscript: direct link, hf CLI and curl.
- Browser
- Download file 467 Bytes
-
https://huggingface.co/spaces/AstraOS/pyscript/resolve/main/static/python/weather_api.py
- Command line
-
hf download hf://spaces/AstraOS/pyscript/static/python/weather_api.py
-
curl -L -o weather_api.py https://huggingface.co/spaces/AstraOS/pyscript/resolve/main/static/python/weather_api.py
467 Bytes
| import io | |
| import json | |
| # noinspection PyUnresolvedReferences | |
| import pyodide | |
| class Report: | |
| # noinspection PyDefaultArgument | |
| def __init__(self, data={}): | |
| self.report_summary: str = data.get('report') | |
| self.sky: str = data.get('sky') | |
| self.temp: int = int(data.get('temp', 0)) | |
| def download_report() -> Report: | |
| resp: io.StringIO = pyodide.open_url('/weather/data') | |
| forecast = json.loads(resp.read()) | |
| return Report(forecast) | |