MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / create_endpoint

Function create_endpoint

DemoPrograms/Demo_Desktop_Widget_Weather.py:130–147  ·  view source on GitHub ↗

Create the api request endpoint {0: default, 1: zipcode, 2: city_name}

(endpoint_type=0)

Source from the content-addressed store, hash-verified

128
129
130def create_endpoint(endpoint_type=0):
131 """ Create the api request endpoint
132 {0: default, 1: zipcode, 2: city_name}"""
133 if endpoint_type == 1:
134 try:
135 endpoint = f"http://api.openweathermap.org/data/2.5/weather?zip={APP_DATA['Postal']},{APP_DATA['Country']}&appid={API_KEY}&units={APP_DATA['Units']}"
136 return endpoint
137 except ConnectionError:
138 return
139 elif endpoint_type == 2:
140 try:
141 # endpoint = f"http://api.openweathermap.org/data/2.5/weather?q={APP_DATA['City'].replace(' ', '%20')},us&APPID={API_KEY}&units={APP_DATA['Units']}"
142 endpoint = f"http://api.openweathermap.org/data/2.5/weather?q={APP_DATA['City'].replace(' ', '%20')},{APP_DATA['Country']}&APPID={API_KEY}&units={APP_DATA['Units']}"
143 return endpoint
144 except ConnectionError:
145 return
146 else:
147 return
148
149
150def request_weather_data(endpoint):

Callers 1

update_weatherFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected