Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DiscordBot/Weather.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19 lines (15 sloc)
748 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from flask import Flask, jsonify | |
import requests | |
from Key import Weather_key | |
'''Function: Requests the Weather Dictionary from the Open Weather API via Latitude and Longitude. | |
Input: Float(Lat,Lng), Output: Dictionary(Search_json)''' | |
def Forecast(Lat,Lng): | |
Lat = str(Lat) | |
Lng = str(Lng) | |
Weather_Api = "http://api.openweathermap.org/data/2.5/weather?lat="+(Lat)+"&lon="+(Lng) # The Open Weather api Url. | |
Search_Input = { "APPID":Weather_key,} | |
Search_Req = requests.get(Weather_Api,Search_Input) # Requests the specific dictionary from the Open Weather API | |
Search_Json = Search_Req.json() # Json representation of dictionary returned. | |
print("\n",Search_Json) | |
return(Search_Json) # Returns to APIMaps.py | |