Skip to content

Commit 19bde17

Browse files
authored
Add files via upload
1 parent c1d662a commit 19bde17

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Python/Air Quality Detector/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from tkinter import *
2+
import requests
3+
import json
4+
5+
root=Tk()
6+
root.title("Air quality detector")
7+
8+
root.geometry("800x40")
9+
root.configure(background='green')
10+
11+
try:
12+
api_request= requests.get("http://www.airnowapi.org/aq/observation/zipCode/current/?format=application/json&zipCode=20002&distance=10&API_KEY=1415D85E-FB89-40EF-B8F0-63F99A595BC8")
13+
api=json.loads(api_request.content)
14+
city=api[0]['ReportingArea']
15+
quality=api[0]['AQI']
16+
category=api[0]['Category']['Name']
17+
except Exception as e:
18+
api="Error..."
19+
20+
myLabel= Label(root, text="Ahmedabad" + " Air Quality" + str(quality) + " "+ category, font=("Helvetica", 20), background="green")
21+
myLabel.pack()
22+
23+
24+
root.mainloop()

0 commit comments

Comments
 (0)