From the course: Programming Foundations: Application Architecture

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Code walkthrough: App integration with a weather API

Code walkthrough: App integration with a weather API

From the course: Programming Foundations: Application Architecture

Code walkthrough: App integration with a weather API

Let's take a look at a practical example of how an external API can be used in an application. We'll download our dependencies with pip and then use Python to run it in the terminal. If you don't have Python already installed, you can download it at python. org/downloads. If you're on Windows, the command is just Python and not Python3. Let's run it. Our application is running and it's located on Port 5000. Let's open it up in a web page. Here we have a weather web application that tells us the weather of a given city. Let's check the weather for Philadelphia. It looks like it's 75 degrees in Philly. Now, our application doesn't calculate this weather data. It's actually pulled from an official weather provider through the open weather API. Let's see how it works under the hood. This application consists of a simple HTML form, where users can enter a city name and get the current weather conditions. This form sends a POST request to our server when submitted, parsing the city name as…

Contents