Create a Weather app using Flask | Python Last Updated : 17 Sep, 2019 Comments Improve Suggest changes Like Article Like Report Prerequisite : Flask installation Flask is a lightweight framework written in Python. It is lightweight because it does not require particular tools or libraries and allow rapid web development. today we will create a weather app using flask as a web framework. this weather web app will provide current weather updates of cities searched. Basic setup : Create a file and name it as weather.py Linux command to create a file touch weather.py Now, create a folder templates with a file name index.html Linux command to create a folder and a file mkdir templates && cd templates && touch index.html The project folder will look like : Editing files : Use your own API key from Weather API and place it in API variable. Now edit weather.py file. Python3 1== from flask import Flask, render_template, request # import json to load JSON data to a python dictionary import json # urllib.request to make a request to api import urllib.request app = Flask(__name__) @app.route('/', methods =['POST', 'GET']) def weather(): if request.method == 'POST': city = request.form['city'] else: # for default name mathura city = 'mathura' # your API key will come here api = api_key_here # source contain json data from api source = urllib.request.urlopen('http://api.openweathermap.org/data/2.5/weather?q =' + city + '&appid =' + api).read() # converting JSON data to a dictionary list_of_data = json.loads(source) # data for variable list_of_data data = { "country_code": str(list_of_data['sys']['country']), "coordinate": str(list_of_data['coord']['lon']) + ' ' + str(list_of_data['coord']['lat']), "temp": str(list_of_data['main']['temp']) + 'k', "pressure": str(list_of_data['main']['pressure']), "humidity": str(list_of_data['main']['humidity']), } print(data) return render_template('index.html', data = data) if __name__ == '__main__': app.run(debug = True) Navigate to templates/index.html and edit it: link to the index file. Now you can run the server to see the weather app - python weather.py Comment More infoAdvertise with us Next Article Create a Weather app using Flask | Python I itsvinayak Follow Improve Article Tags : Python Web Technologies HTML CSS Web technologies +1 More Practice Tags : python Similar Reads Weather app using Django | Python Our task is to create a Weather app using Django that lets users enter a city name and view current weather details like temperature, humidity, and pressure. We will build this by setting up a Django project, creating a view to fetch data from the OpenWeatherMap API, and designing a simple template 2 min read Building A Weather CLI Using Python Trying to know the weather is something that we all do, every day. But have you ever dreamed of making a tool on your own that can do the same? If yes, then this article is for you. In this article, we will look at a step-by-step guide on how to build a Weather CLI using OpenWeather API. What is Ope 4 min read Weather App in Python using Tkinter module In this article, we are going to discuss how to create a weather app using tkinter. The GUI app will tell us the current weather of a particular city along with temperature details along with other details. Modules required:Tkinter: It is a built-in python library for making GUI using tkinter toolk 4 min read Python | Build a REST API using Flask Prerequisite: Introduction to Rest API REST stands for REpresentational State Transfer and is an architectural style used in modern web development. It defines a set or rules/constraints for a web application to send and receive data. In this article, we will build a REST API in Python using the Fla 3 min read How to Run a Flask Application After successfully creating a Flask app, we can run it on the development server using the Flask CLI or by running the Python script. Simply execute one of the following commands in the terminal:flask --app app_name runpython app_nameFile StructureHere, we are using the following folder and file.Dem 4 min read Like