GithubHelp home page GithubHelp logo

tea-n-tech / professional-python-exercises-1-weatherapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 55 KB

Exercieses complementing the Professional Python course on youtube - first exercise of communicating with an API

License: MIT License

Python 100.00%

professional-python-exercises-1-weatherapi's Introduction

professional-python-exercises-1-weatherAPI

Task

Exercieses complementing the Professional Python course on youtube - first exercise of communicating with an API

Exercise goals:

  • Simple script as start

  • Communicate with an external system

  • Output things to console

  • Fetch weather data

    • Weather history data last 3 days
    • Weather forecast for next 3 days
    • Extra: Display a temperature map (past or future)

Function of the code in this repository

  • The OpenWeatherMap API has been used in this repository (https://openweathermap.org/api, version 2.5 as this is free for use)
  • The free version will require an API key which is asked for at the beginning of the execution of the script
  • Basically the Script asks the user to input a city for which to generate a forcast
  • The forcast is set to be at least 3 days (25 timestamps in 3 hours intervals)
  • Local caching is activated
    • The json response from the api is saved as a file in the directory of the script
    • When executed again and less than one day has passed and the same location is required, the api is not triggered again but rather cached data is being read in
    • If the file is deleted the api is triggered anyway as loading from cache is impossible

Usage

  • Install the requirements with
    • pip install -r requirements.txt
  • The api key can be stored in a local .env file with the following scheme: TNT_EX1_OPENWEATHERMAP_API_KEY='API__KEY__PLACEHOLDER'
    • User is asked to input an api-key if no api key can be found
    • The given key is saved into the .env file for future use
  • Run the Python file: WeatherDataFetcher.py with python WeatherDataFetcher.py
  • Input data as required

professional-python-exercises-1-weatherapi's People

Contributors

manuel1618 avatar

Watchers

Codie (蒂诺) avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.