{"id":3188,"date":"2024-04-17T17:01:41","date_gmt":"2024-04-17T17:01:41","guid":{"rendered":"https:\/\/www.infobip.com\/developers\/?p=3188"},"modified":"2024-04-17T17:01:41","modified_gmt":"2024-04-17T17:01:41","slug":"building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk","status":"publish","type":"post","link":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk","title":{"rendered":"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK"},"content":{"rendered":"\n<p>In this post, you\u2019ll create a weather app built with Flask to gather accurate weather reports of a location based on city name, state code, and country code. This app will use the Infobip Python SDK and send the info to your phone.&nbsp;<\/p>\n\n\n\n<p>The complete source code for this project is in <a href=\"https:\/\/github.com\/Terieyenike\/weatherapi-with-python\">this GitHub repo<\/a>, which you can try for yourself.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Before you begin<\/h2>\n\n\n\n<p>The following are must-haves to complete this tutorial.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Understanding of Python and the Flask framework<\/li>\n\n\n\n<li>Python 3 installed on your development system<\/li>\n\n\n\n<li>An Infobip account. <a href=\"https:\/\/www.infobip.com\/signup?signup_source=DevRelCampaign\">Sign up<\/a> for a free trial<\/li>\n\n\n\n<li><a href=\"https:\/\/home.openweathermap.org\/users\/sign_up\">OpenWeatherMap API<\/a> &#8211; create an account for free<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Setup and installation<\/h2>\n\n\n\n<p>Since we are using the <strong>Flask<\/strong> framework for the entire workflow of this tutorial, you need to create a <code>weatherapi-with-python<\/code> directory in your file system, which will contain all the project files and directories.<\/p>\n\n\n\n<p>To bootstrap this app, run this command in the terminal window, which creates a virtual environment to manage all the dependencies for your project.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir weatherapi-with-python\ncd weatherapi-with-python\npython3 -m venv .venv\nsource .venv\/bin\/activate<\/code><\/pre>\n\n\n\n<p>The <strong><code>source<\/code><\/strong> command activates the environment and shows the name of the activated environment.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(.venv) (base) \u2601  weatherapi-with-python<\/code><\/pre>\n\n\n\n<p>Flask will handle the application&#8217;s client side, allowing users to interact with the app using Python, and it will send notifications to your phone via SMS.<\/p>\n\n\n\n<p>Let\u2019s install the following Python packages within the activated environment to make this happen.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install Flask\npip install infobip-api-python-sdk<\/code><\/pre>\n\n\n\n<p>The <strong>Infobip SDK<\/strong> is the Python package responsible for sending SMS messages. It is also effective in other communication channels like WhatsApp, Email, MMS, and so on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Environment variables<\/h2>\n\n\n\n<p>The environment variables cut across different programming languages, which serve as a file to keep secrets and protect them from being leaked when pushing your code to GitHub.<\/p>\n\n\n\n<p>Create a \u201c.env\u201d file within the top level of your working directory and include the OpenWeatherMap API.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OWM_API_KEY=\"&lt;open-weather-map-api-key&gt;\"<\/code><\/pre>\n\n\n\n<p>PS: Replace the value in quotes with yours.<\/p>\n\n\n\n<p>Also, for the safety of your private keys, create a <strong>.gitignore<\/strong> file and include the <strong>.env<\/strong> file. You can include other files you do not want to share.<\/p>\n\n\n\n<p>Your directory structure will look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>weatherapi-with-python\/\n        .env\n        .gitignore<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Implementing the weather data retrieval module, <code>weather.py<\/code><\/h2>\n\n\n\n<p>Before updating the project with code, we will work with two Python files for different purposes.<br>First, create the <code>weather.py<\/code> file in the working directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>weatherapi-with-python\/\n        .env\n        .gitignore\n        weather.py<\/code><\/pre>\n\n\n\n<p>The dependencies for this project will include the following in the <code>requirements.txt<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Flask\nrequests\npython-dotenv\ninfobip-api-python-sdk<\/code><\/pre>\n\n\n\n<p>You can run <code>pip install -r requirements.txt<\/code> to make sure these are all installed.<\/p>\n\n\n\n<p>The updated directory structure will look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>weatherapi-with-python\/\n        .env\n        .gitignore\n        weather.py\n        requirements.txt<\/code><\/pre>\n\n\n\n<p>Copy-paste this code into <code>weather.py<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import requests\nimport os\nfrom dotenv import load_dotenv\nfrom dataclasses import dataclass\n\n\nload_dotenv()\nAPI_KEY = os.environ&#91;\"OWM_API_KEY\"]\nOWM_ENDPOINT = \"https:\/\/api.openweathermap.org\/data\/2.5\/weather\"\n\n@dataclass\nclass WeatherData:\n    main: str\n    description: str\n    latitude: float\n    longitude: float\n    temperature: int\n\ndef get_lat_lon(city_name, state_code, country_code, API_KEY):\n    resp = requests.get(f'http:\/\/api.openweathermap.org\/geo\/1.0\/direct?q={city_name},{state_code},{country_code}&amp;appid={API_KEY}')\n    data = resp.json()\n    if data:\n        location = data&#91;0]\n        return location.get('lat'), location.get('lon')\n    else:\n        return None, None\n\n\ndef get_current_weather(lat, lon, API_KEY):\n    params = {\n        \"lat\": lat,\n        \"lon\": lon,\n        \"appid\": API_KEY,\n        \"units\": \"metric\"\n    }\n    resp = requests.get(OWM_ENDPOINT, params=params)\n    data = resp.json()\n    weather = data&#91;\"weather\"]&#91;0]\n    main = weather&#91;\"main\"]\n    description = weather&#91;\"description\"]\n    latitude = float(data&#91;\"coord\"]&#91;\"lat\"])\n    longitude = float(data&#91;\"coord\"]&#91;\"lon\"])\n    temperature = int(data&#91;\"main\"]&#91;\"temp\"])\n    return WeatherData(main, description, temperature, latitude, longitude)\n\n\ndef main(city_name, state_name, country_name):\n    lat, lon = get_lat_lon(city_name, state_name, country_name, API_KEY)\n    weather_data = get_current_weather(lat, lon, API_KEY)\n    return weather_data\n\nif __name__ == \"__main__\":\n    lat, lon = get_lat_lon(\"Yakutsk\", \"YA\", \"RU\", API_KEY)\n    if lat is not None and lon is not None:\n        weather_data = get_current_weather(lat, lon, API_KEY)\n        if weather_data is not None:\n            print(weather_data)\n        else:\n            print(\"Failed to retrieve weather data.\")\n    else:\n        print(\"Failed to retrieve latitude and longitude.\")\n<\/code><\/pre>\n\n\n\n<p>We import the various modules &#8211; <code>requests<\/code>, <code>os<\/code>, <code>dotenv<\/code>, and <code>dataclasses<\/code> &#8211; using the <code>import <\/code>statement.<\/p>\n\n\n\n<p>Next is to call <code>load_dotenv()<\/code> to gain access to the environment variable and define the variables <code>API_KEY<\/code> and <code>OWM_Endpoint<\/code>.<\/p>\n\n\n\n<p>The <code>@dataclass<\/code> decorator creates a structure with data classes to access only the information we need from the OpenWeather API endpoint response objects. That means we define a data class object to store and retrieve the necessary information with their data types mapped to the keys.<\/p>\n\n\n\n<p>The <code>get_lat_lon<\/code> function takes in the parameters, and within the function, it reads data from the <code>json()<\/code> objects and returns the latitude and longitude of a particular location.<\/p>\n\n\n\n<p>The <code>get_current_weather<\/code> function will access the current weather data for any location on earth and return the <code>WeatherData<\/code> class, accepting the parameters from the data classes defined in the <code>@dataclass<\/code> decorator.<\/p>\n\n\n\n<p>In the defined <code>main<\/code> function, we pass the already defined <code>get_lat_lon<\/code> and <code>get_current_weather<\/code> function, which will be imported as a module in the <code>app.py<\/code> file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the <code>app.py<\/code><\/h2>\n\n\n\n<p>In the root directory, create the <code>app.py<\/code> file, the app&#8217;s entry point containing the code to send an SMS. The structure of the directory will be as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>weatherapi-with-python\/\n        .env\n        .gitignore\n        app.py\n        weather.py\n        requirements.txt<\/code><\/pre>\n\n\n\n<p>At this point, add these lines of code to the <code>app.py<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from flask import Flask\n\napp = Flask(__name__)\n\n@app.route(\u201c\/\u201d)\ndef index():\n    return \u201cweather app!\u201d<\/code><\/pre>\n\n\n\n<p>Start the development server with the command <code>flask run<\/code>, which outputs the port on <code>localhost:5000<\/code> and displays the message <code>weather app!<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the layout view<\/h2>\n\n\n\n<p>The layout view handles how the page structure looks using HTML elements. Behind the scenes, Flask uses the <strong>templates<\/strong> folder to be able to render the page properly.&nbsp;<\/p>\n\n\n\n<p>In the working directory, create a new directory called <strong>templates <\/strong>and, inside this folder, add a file called <code>index.html <\/code>with the following code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"UTF-8\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;meta\n      name=\"description\"\n      content=\"Using the open weather API and Infobip to send reports of the weather at a specific location as SMS\" \/&gt;\n    &lt;title&gt;Get accurate weather reports from anywhere&lt;\/title&gt;\n    &lt;script src=\"https:\/\/cdn.tailwindcss.com\"&gt;&lt;\/script&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;div class='min-h-screen py-8 flex flex-col overflow-hidden'&gt;\n      &lt;h1 class=\"text-3xl font-bold text-center mb-5\"&gt;Weather App&lt;\/h1&gt;\n      &lt;div class=\"container max-w-7xl mx-auto w-3\/4\"&gt;\n        &lt;form action=\"{{url_for(\"index\")}}\" method=\"POST\"&gt;\n          &lt;div&gt;\n            &lt;label for=\"cityName\" class=\"block text-gray-700 font-bold mb-2\"\n              &gt;City name&lt;\/label\n            &gt;\n            &lt;input\n              type=\"text\"\n              id=\"cityName\"\n              required\n              name=\"cityName\"\n              placeholder=\"city\"\n              class=\"w-full px-4 py-2 border rounded-lg mb-5 mt-3 text-gray-700 bg-white border-gray-300 appearance-none block leading-normal focus:outline-none\" \/&gt;\n          &lt;\/div&gt;\n          &lt;div&gt;\n            &lt;label for=\"stateName\" class=\"block text-gray-700 font-bold mb-2\"\n              &gt;State code&lt;\/label\n            &gt;\n            &lt;input\n              type=\"text\"\n              id=\"stateName\"\n              required\n              name=\"stateName\"\n              placeholder=\"KD\"\n              class=\"w-full px-4 py-2 border rounded-lg mb-5 mt-3 text-gray-700 bg-white border-gray-300 appearance-none block leading-normal focus:outline-none\" \/&gt;\n          &lt;\/div&gt;\n          &lt;div&gt;\n            &lt;label for=\"countryName\" class=\"block text-gray-700 font-bold mb-2\"\n              &gt;Country code&lt;\/label\n            &gt;\n            &lt;input\n              type=\"text\"\n              id=\"countryName\"\n              required\n              name=\"countryName\"\n              placeholder=\"NG\"\n              class=\"w-full px-4 py-2 border rounded-lg mb-5 mt-3 text-gray-700 bg-white border-gray-300 appearance-none block leading-normal focus:outline-none\" \/&gt;\n          &lt;\/div&gt;\n          &lt;button\n            type=\"submit\"\n            class=\"flex-shrink-0 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-none hover:bg-indigo-600 rounded text-lg mt-8 sm:mt-0\"&gt;\n            SMS weather report\n          &lt;\/button&gt;\n        &lt;\/form&gt;\n      &lt;\/div&gt;\n      &lt;footer class=\"mt-auto flex items-center justify-center\"&gt;\n        &lt;p&gt;Infobip &amp;copy; 2024. Build by Teri&lt;\/p&gt;\n      &lt;\/footer&gt;\n    &lt;\/div&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<p>The project directory tree now looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>weatherapi-with-python\/\n        .env\n        .gitignore\n        app.py\n        weather.py\n        requirements.txt\n        templates\/\n                index.html<\/code><\/pre>\n\n\n\n<p>The <code>&lt;head&gt;<\/code> section contains the meta description: the web app&#8217;s information, title, and Tailwind CSS CDN in the script tag. Tailwind CSS provides utility-first CSS classes within the HTML elements.<\/p>\n\n\n\n<p>The <code>&lt;body&gt;<\/code> section comprises the HTML <code>&lt;form&gt;<\/code> tag wrapped around the text input that accepts values from the user and a button that sends a POST request on click.<\/p>\n\n\n\n<p>Next, to handle the request from the <code>index.html<\/code>, let\u2019s update the <code>app.py <\/code>file with the <code>render_template()<\/code> method, which renders a template and request object used to access request data from the input.<\/p>\n\n\n\n<p>Update your <code>app.py<\/code> file with this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from flask import Flask, render_template, request\nfrom weather import main as get_weather<\/code><\/pre>\n\n\n\n<p>The weather module is from the <code>weather.py<\/code> file, and the main function with an alias of <code>get_weather<\/code>.<br><br>Also, update the <code>index()<\/code> function as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route(\"\/\", methods=&#91;\"GET\", \"POST\"])\ndef index():\n    data = None\n    degree_sign = u\"\\N{DEGREE SIGN}\"\n    if request.method == \"POST\":\n        city_name = request.form.get(\"cityName\")\n        state_code = request.form.get(\"stateName\")\n        country_code = request.form.get(\"countryName\")\n        data = get_weather(city_name, state_code, country_code)\n        if city_name and state_code and country_code:\n            data = get_weather(city_name, state_code, country_code)\n            message = f\"Weather for {city_name.title()}(lat: {data.latitude}, lon: {data.longitude}): temperature of {data.temperature}{degree_sign}C with {data.description}\"\n            print(message)\n    return render_template(\"index.html\")<\/code><\/pre>\n\n\n\n<p>The above code snippets run only when the condition is met for the HTTP method POST request. The <code>index()<\/code> function queries the OpenWeather API to get the values for the location entered in the input fields. It displays accurate info for latitude, longitude, name of the city, temperature, and the description of the weather in the terminal.<br><br>To continually reload the page on file change, enable the debug mode using the <code>--debug<\/code> option in the terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>flask --app app run --debug<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"713\" src=\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weather-app-1024x713.png\" alt=\"\" class=\"wp-image-3189\" srcset=\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weather-app-1024x713.png 1024w, https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weather-app-300x209.png 300w, https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weather-app-768x534.png 768w, https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weather-app.png 1075w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Integrating with Infobip Python SDK for SMS notifications<\/h2>\n\n\n\n<p>To use and integrate Infobip into the application, you need the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Infobip API key<\/li>\n\n\n\n<li>The base URL<\/li>\n\n\n\n<li>Your phone number you like to send the SMS. If this is a trial account, your verified number for the platform is what is used<\/li>\n<\/ul>\n\n\n\n<p>All this information can be accessed from your <a href=\"https:\/\/portal.infobip.com\/dev\/api-keys\">user portal dashboard<\/a> after logging in to your account.<\/p>\n\n\n\n<p>To learn more, check out <a href=\"https:\/\/www.infobip.com\/docs\/essentials\/base-url\">the documentation<\/a>.<\/p>\n\n\n\n<p>Let\u2019s include these three variables from your user portal dashboard in the <code>.env<\/code> file as shown:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OWM_API_KEY=\"&lt;open-weather-map-api-key&gt;\"\n<strong>IB_BASE_URL=\"&lt;your API Base URL&gt;\"\nIB_API_KEY=\"&lt;your API Key&gt;\"\nDESTINATION_NUMBER=\"&lt;your phone number&gt;\"<\/strong><\/code><\/pre>\n\n\n\n<p>The Infobip Python SDK uses the first two variables, <code>IB_BASE_URL<\/code> and <code>IB_API_KEY<\/code>, under the hood. At the same time, the destination number will be accessed directly in the code using the <code>os.environ<\/code>, which means accessing the stored environment variables from the `.env` file.<\/p>\n\n\n\n<p><strong>PS<\/strong>: Ensure you use the same naming convention for the Infobip variables in the <code>.env<\/code> file for the app to function.<\/p>\n\n\n\n<p>Now import these two modules into the <code>app.py<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from infobip_channels.sms.channel import SMSChannel\nimport os<\/code><\/pre>\n\n\n\n<p>Finally, add this function:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def send_sms_from_app(text):\n    channel = SMSChannel.from_env()\n    sms_response = channel.send_sms_message({\n        'messages': &#91;{\n            'from': 'Real-time weather info',\n            'text': text,\n            'destinations': &#91;{\n                'to': os.environ&#91;'DESTINATION_NUMBER']\n            }],\n        }]\n    })\n    print(sms_response)<\/code><\/pre>\n\n\n\n<p>The <code>send_sms_from_app<\/code> function accepts a <code>text<\/code> parameter and sets up the SMS channel from the variables set earlier. After that, the channel uses the object to send the SMS, accepting a message title from the sender and the text, which will be the actual weather data report and the destination number of the recipient.<\/p>\n\n\n\n<p>To validate that the message is sent, we print out a response from the API showing the status code OK of `200` in the terminal.<\/p>\n\n\n\n<p>Now, replace the <code>print(message)<\/code> in the <code>index<\/code> function with the <code>send_sms_from_app<\/code> function, passing the arguments, <code>message<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route(\"\/\", methods=&#91;\"GET\", \"POST\"])\ndef index():\n    data = None\n    degree_sign = u\"\\N{DEGREE SIGN}\"\n    if request.method == \"POST\":\n        city_name = request.form.get(\"cityName\")\n        state_code = request.form.get(\"stateName\")\n        country_code = request.form.get(\"countryName\")\n        data = get_weather(city_name, state_code, country_code)\n        if city_name and state_code and country_code:\n            data = get_weather(city_name, state_code, country_code)\n            message = f\"Weather for {city_name.title()}(lat: {data.latitude}, lon: {data.longitude}): temperature of {data.temperature}{degree_sign}C with {data.description}\"\n            send_sms_from_app(message)\n    return render_template(\"index.html\")<\/code><\/pre>\n\n\n\n<p>This code snippet sends an instant message to the destination number on click of the button, <strong>SMS weather report<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The ability to send reports in real-time makes Infobip a great choice, as it is packed with a rich set of tools that can be expanded to reach a wider audience on mobile devices. If you add more features to this demo app, share it with us <a href=\"https:\/\/discord.com\/invite\/G9Gr6fk2e4\">on Discord<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, you\u2019ll create a weather app built [&hellip;]<\/p>\n","protected":false},"author":53,"featured_media":3190,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[28,12,13],"tags":[43,76],"coauthors":[293],"class_list":["post-3188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-post","category-guide","category-python","tag-api","tag-sdk"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK - Infobip Developers Hub<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK - Infobip Developers Hub\" \/>\n<meta property=\"og:description\" content=\"In this post, you\u2019ll create a weather app built [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\" \/>\n<meta property=\"og:site_name\" content=\"Infobip Developers Hub\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/infobip\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-17T17:01:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Teri Eyenike\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InfobipDev\" \/>\n<meta name=\"twitter:site\" content=\"@InfobipDev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Teri Eyenike\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\"},\"author\":{\"name\":\"Eli Holderness\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/2d3f818bd258646bc997a3ec04146bbd\"},\"headline\":\"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK\",\"datePublished\":\"2024-04-17T17:01:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\"},\"wordCount\":1187,\"publisher\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png\",\"keywords\":[\"API\",\"SDK\"],\"articleSection\":[\"Blog Post\",\"Guide\",\"Python\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\",\"url\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\",\"name\":\"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK - Infobip Developers Hub\",\"isPartOf\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png\",\"datePublished\":\"2024-04-17T17:01:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage\",\"url\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png\",\"contentUrl\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png\",\"width\":600,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.infobip.com\/developers\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#website\",\"url\":\"https:\/\/www.infobip.com\/developers\/\",\"name\":\"Infobip Developers Hub\",\"description\":\"Build meaningful customer relationships across any channel\",\"publisher\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.infobip.com\/developers\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\",\"name\":\"Infobip Developers Hub\",\"url\":\"https:\/\/www.infobip.com\/developers\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png\",\"contentUrl\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png\",\"width\":696,\"height\":696,\"caption\":\"Infobip Developers Hub\"},\"image\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/infobip\/\",\"https:\/\/x.com\/InfobipDev\",\"https:\/\/www.youtube.com\/channel\/UCUPSTy53VecI5GIir3J3ZbQ\",\"https:\/\/github.com\/infobip-community\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/2d3f818bd258646bc997a3ec04146bbd\",\"name\":\"Eli Holderness\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/image\/e3fd4a8aa6b78952d057f724bcf1dff0\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2261319993db9030e1328c712ee20e4aaedf2c9cb8e4379ae8af57f2c877d5f4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2261319993db9030e1328c712ee20e4aaedf2c9cb8e4379ae8af57f2c877d5f4?s=96&d=mm&r=g\",\"caption\":\"Eli Holderness\"},\"description\":\"Developer advocate, conference speaker &amp; professional nerd. Likes maths, knitting, and cats.\",\"url\":\"https:\/\/www.infobip.com\/developers\/blog\/author\/eli\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK - Infobip Developers Hub","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk","og_locale":"en_US","og_type":"article","og_title":"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK - Infobip Developers Hub","og_description":"In this post, you\u2019ll create a weather app built [&hellip;]","og_url":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk","og_site_name":"Infobip Developers Hub","article_publisher":"https:\/\/www.facebook.com\/infobip\/","article_published_time":"2024-04-17T17:01:41+00:00","og_image":[{"width":600,"height":400,"url":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png","type":"image\/png"}],"author":"Teri Eyenike","twitter_card":"summary_large_image","twitter_creator":"@InfobipDev","twitter_site":"@InfobipDev","twitter_misc":{"Written by":"Teri Eyenike","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#article","isPartOf":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk"},"author":{"name":"Eli Holderness","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/2d3f818bd258646bc997a3ec04146bbd"},"headline":"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK","datePublished":"2024-04-17T17:01:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk"},"wordCount":1187,"publisher":{"@id":"https:\/\/www.infobip.com\/developers\/#organization"},"image":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage"},"thumbnailUrl":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png","keywords":["API","SDK"],"articleSection":["Blog Post","Guide","Python"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk","url":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk","name":"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK - Infobip Developers Hub","isPartOf":{"@id":"https:\/\/www.infobip.com\/developers\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage"},"image":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage"},"thumbnailUrl":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png","datePublished":"2024-04-17T17:01:41+00:00","breadcrumb":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#primaryimage","url":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png","contentUrl":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2024\/04\/weatherappcover.png","width":600,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.infobip.com\/developers\/blog\/building-a-flask-app-get-instant-weather-reports-on-your-phone-with-the-infobip-python-sdk#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.infobip.com\/developers\/"},{"@type":"ListItem","position":2,"name":"Building a Flask App: Get Instant Weather Reports on Your Phone with the Infobip Python SDK"}]},{"@type":"WebSite","@id":"https:\/\/www.infobip.com\/developers\/#website","url":"https:\/\/www.infobip.com\/developers\/","name":"Infobip Developers Hub","description":"Build meaningful customer relationships across any channel","publisher":{"@id":"https:\/\/www.infobip.com\/developers\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.infobip.com\/developers\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.infobip.com\/developers\/#organization","name":"Infobip Developers Hub","url":"https:\/\/www.infobip.com\/developers\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/","url":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png","contentUrl":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png","width":696,"height":696,"caption":"Infobip Developers Hub"},"image":{"@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/infobip\/","https:\/\/x.com\/InfobipDev","https:\/\/www.youtube.com\/channel\/UCUPSTy53VecI5GIir3J3ZbQ","https:\/\/github.com\/infobip-community"]},{"@type":"Person","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/2d3f818bd258646bc997a3ec04146bbd","name":"Eli Holderness","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/image\/e3fd4a8aa6b78952d057f724bcf1dff0","url":"https:\/\/secure.gravatar.com\/avatar\/2261319993db9030e1328c712ee20e4aaedf2c9cb8e4379ae8af57f2c877d5f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2261319993db9030e1328c712ee20e4aaedf2c9cb8e4379ae8af57f2c877d5f4?s=96&d=mm&r=g","caption":"Eli Holderness"},"description":"Developer advocate, conference speaker &amp; professional nerd. Likes maths, knitting, and cats.","url":"https:\/\/www.infobip.com\/developers\/blog\/author\/eli"}]}},"_links":{"self":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/3188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/users\/53"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/comments?post=3188"}],"version-history":[{"count":4,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/3188\/revisions"}],"predecessor-version":[{"id":3195,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/3188\/revisions\/3195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/media\/3190"}],"wp:attachment":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/media?parent=3188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/categories?post=3188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/tags?post=3188"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/coauthors?post=3188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}