-- Form to enter the zip code SELECT 'form' AS component, 'multipart/form-data' AS enctype; SELECT 'zip_code' AS name, 'text' AS type, 'Enter your zip code' AS placeholder; -- Define the API key SET $api_key = sqlpage.environment_variable('MY_API_TOKEN'); -- Set a default value for the zip code if not provided SET $zip_code = COALESCE(:zip_code, '07006'); -- Fetch weather data from OpenWeatherMap API WITH weather_data AS ( SELECT sqlpage.fetch( CONCAT( 'https://api.openweathermap.org/data/2.5/weather?zip=', $zip_code, '&appid=', $api_key, '&units=imperial' ) ) AS json_data ) -- Extract wind speed and temperature SELECT 'text' AS component, 'Wind speed is ' || json_extract(json_data, '$.wind.speed') || ', and temperature is ' || json_extract(json_data, '$.main.temp') AS contents FROM weather_data;