This app uses OpenWeatherMap to fetch weather data.
Current 'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_token}'
Forecast 'http://api.openweathermap.org/data/2.5/forecast?q={city}&cnt={days_count}&appid={api_token}'
- Define and call a function
- Format strings using f-strings
- Use urllib to make requests to the API
- Create a virtualenv for managing dependencies
- Go to open weather map, create a user and API token. Explore the different APIs.
- Copy the contents of
.env.dev
file into a new file named.env
, create and fill in the missing API token. 1a. If you are a beginner, it is suggested that you go through the tutorial inget_started.py
before continuing with the rest of the steps. - Create a python 3 virtualenv and install reqirements from
requirements.txt
. - Current weather:
- Prompt the user for a city name and fetch the current weather data using the current weather URL.
- Print city, country, temperature in celsius, humidity, weather type of the current weather data of the city.
- Make a function that converts temperatures from kelvin to celsius
- Weather forecast:
- Prompt the user for a city name and a count of days and fetch the weather forecast using the forecast URL.
- Run
myapp.py
to run the Flask app.