Skip to content

Instantly share code, notes, and snippets.

@discdiver
Created September 20, 2023 15:28
Show Gist options
  • Select an option

  • Save discdiver/93999e38db5249d7dc718e90134b18ab to your computer and use it in GitHub Desktop.

Select an option

Save discdiver/93999e38db5249d7dc718e90134b18ab to your computer and use it in GitHub Desktop.

Revisions

  1. discdiver renamed this gist Sep 20, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. discdiver created this gist Sep 20, 2023.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import requests
    from prefect import flow


    @flow(log_prints=True)
    def fetch_weather(lat: float = 38.9, lon: float = -77.0):
    weather = requests.get(
    "https://api.open-meteo.com/v1/forecast/",
    params=dict(latitude=lat, longitude=lon, hourly="temperature_2m"),
    )
    most_recent_temp = float(weather.json()["hourly"]["temperature_2m"][0])
    print(f"Most recent temp C: {most_recent_temp} degrees")
    return


    if __name__ == "__main__":
    fetch_weather.serve(name="get-weather", cron="0 0 * * *")