mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2025-01-30 21:23:43 +00:00
Weather Text
Initial weather text app
This commit is contained in:
parent
99987da841
commit
59a294dc2b
37
weather_text/weather_text.py
Normal file
37
weather_text/weather_text.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
from twilio.rest import Client
|
||||||
|
|
||||||
|
|
||||||
|
api_key = os.environ['API_KEY']
|
||||||
|
base_url = os.environ['BASE_URL']
|
||||||
|
|
||||||
|
zip_code = input("Enter your Zip code: ")
|
||||||
|
region = input("Enter your region: ")
|
||||||
|
complete_url = base_url + "zip=" + zip_code + "," + region + "&appid=" + api_key
|
||||||
|
response = requests.get(complete_url)
|
||||||
|
x = response.json()
|
||||||
|
|
||||||
|
if x["cod"] != "404" :
|
||||||
|
y = x["main"]
|
||||||
|
current_temp = y["temp"]
|
||||||
|
|
||||||
|
conversion_temp = (current_temp - 273.15) * 9/5 + 32
|
||||||
|
|
||||||
|
account_sid = os.environ['TWILIO_SID']
|
||||||
|
auth_token = os.environ['AUTH_TOKEN']
|
||||||
|
client = Client(account_sid, auth_token)
|
||||||
|
|
||||||
|
numFrom = input("Enter your number: ")
|
||||||
|
numTo = input("Enter your sender number: ")
|
||||||
|
|
||||||
|
|
||||||
|
message = client.messages \
|
||||||
|
.create(
|
||||||
|
body="Temperature is: " + str(conversion_temp),
|
||||||
|
from_=numFrom,
|
||||||
|
to= numTo
|
||||||
|
)
|
||||||
|
print(message.sid)
|
Loading…
Reference in New Issue
Block a user