Skip to content

Commit

Permalink
apikey update
Browse files Browse the repository at this point in the history
  • Loading branch information
arturfriedrich committed Jun 5, 2023
1 parent 9ee752e commit 21b4a1e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions current_weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

source printer.sh

# Set OpenWeatherMap API key, write your own API key here
apikey=$(cat apikeyfile.txt)
API_KEY=$apikey

# Define function to retrieve weather information
get_weather_information() {
local location=$1
local apikey=$2

# Set OpenWeatherMap API key, write your own API key here
apikey=$(cat apikeyfile.txt)
API_KEY=$apikey

# Call OpenWeatherMap API and retrieve weather data
weather_data=$(curl -s "http://api.openweathermap.org/data/2.5/weather?q=${location}&appid=${API_KEY}")
Expand Down
9 changes: 5 additions & 4 deletions forecast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

source printer.sh

# Set OpenWeatherMap API key, write your own API key here
apikey=$(cat apikeyfile.txt)
API_KEY=$apikey

get_weather_forecast() {
local location=$1
local apikey=$2

# Set OpenWeatherMap API key, write your own API key here
apikey=$(cat apikeyfile.txt)
API_KEY=$apikey

# Call OpenWeatherMap API and retrieve weather forecast data
forecast_data=$(curl -s "http://api.openweathermap.org/data/2.5/forecast?q=${location}&appid=${API_KEY}")
Expand Down
4 changes: 2 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ read -p "Do you want to display the current weather or the forecast for 5 days:
# Check the value of display_mode and take appropriate action
if [ "$display_mode" = "c" ]; then
# Display current weather information
get_weather_information "$location"
get_weather_information "$location" "$apikey"
elif [ "$display_mode" = "f" ]; then
# Display weather forecast for 5 days
get_weather_forecast "$location"
get_weather_forecast "$location" "$apikey"
else
echo "Invalid input!"
fi

0 comments on commit 21b4a1e

Please sign in to comment.