Ana Sayfa / Kod ve Scriptler / LocationWeatherAPI - Python
LocationWeatherAPI - Python
Diyet tercihleri, malzemeler ve yemek pişirme tercihlerine göre kişiselleştirilmiş tarif önerileri sunan API.
- Yayın tarihi20 Haziran 2023
- Son güncelleme20 Haziran 2023

Overview
LocationWeatherAPI is a simple API built using the Flask framework that allows users to retrieve current weather information for a specific city.
By making a GET request to the /weather endpoint with the city parameter, users can obtain the temperature and description of the weather in that city.
The API requires an API key obtained from a weather API provider, which is included in the code before running the API. It utilizes the requests library to send HTTP requests to the weather API provider's endpoint and fetches the current weather data in JSON format. The API ensures parameter validation by checking if the city parameter is provided and returns an appropriate error message if it is missing. It also supports language localization by specifying the 'lang' parameter as 'en' to receive weather information in English. When the weather data is successfully retrieved, the API constructs a JSON response containing the city, temperature, and weather description. If there are any errors during the retrieval process or if the response status code is not 200, an error message is returned instead. By following the provided instructions, users can set up and run the Flask weather API on their local machine, allowing them to access weather information by sending HTTP GET requests to the API's endpoint.
Features
- Weather data retrieval: The API allows users to retrieve weather information for a specific city.
- Parameter validation: The API checks if the 'city' parameter is provided and returns an appropriate error message if it's missing.
- API key usage: The API uses an API key to authenticate requests to the weather API provider.
- Language support: The API specifies the 'lang' parameter as 'en' to receive weather information in English.
- JSON response: The API returns weather data in JSON format.
- Error handling: If there's an error while fetching weather data or if the response status code is not 200, the API returns an error message.
Requirements
- Flask: The code requires the Flask framework to run the API.
- requests: The code uses the requests library to send HTTP requests to the weather API.
- API key: You need to obtain an API key from the weather API provider and replace '8555c38230c044a8a40152819231606' with your actual API key.
- Weather API endpoint: The code relies on the 'https://api.weatherapi.com/v1/current.json' endpoint to fetch weather data.
- Route configuration: The code sets up a route at '/weather' for handling weather API requests with the HTTP GET method.
- 'GET' method: The API supports only the GET method for retrieving weather data.
- City parameter: The API expects the 'city' parameter to be provided as a query parameter in the API endpoint URL.
- Temperature and description: The API extracts the current temperature and weather description from the weather API response to include them in the result.
Benzer ürünler

Uzun videolarda viral anları bulan, altyazılar üreten ve paylaşıma hazır klipleri dışa aktaran AI destekli araç.
Yayın: Nisan 2026
Canlı API verilerini kullanarak gerçek zamanlı para birimi dönüşümü yapan, temiz ve kolay entegre edilebilir kodlu hassas bir Python scripti
Yayın: Aralık 2025
Eksiksiz flört uygulaması kaynak kodu: Python Flask arka uç, yönetim paneli, sohbet ve abonelikler.
Yayın: Kasım 2026
Python Flask ile geliştirilmiş otomatik SMM Paneli betiği; cüzdan yükleme, kademeli fiyatlandırma ve API sağlayıcı entegrasyonu.
Yayın: Ekim 2026
Gönderiler, hikâyeler, sohbet, aramalar, yapay zeka araçları, premium özellikler ve daha fazlasıyla tam özellikli Flask sosyal blog platformu.
Yayın: Ekim 2026
Otomatik kurumsal belge iş akışları ve dijital varlık yönetimi için tasarlanmış, üretime hazır bir Python SaaS web uygulaması.
Yayın: Temmuz 2026