Skip to content

turkupy/beginners-python-weather

Repository files navigation

Weather Assembler

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}'

Techniques you will need

Study project

  1. Go to open weather map, create a user and API token. Explore the different APIs.
  2. 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 in get_started.py before continuing with the rest of the steps.
  3. Create a python 3 virtualenv and install reqirements from requirements.txt.
  4. 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
  1. Weather forecast:
  • Prompt the user for a city name and a count of days and fetch the weather forecast using the forecast URL.

Flask

  1. Run myapp.py to run the Flask app.