o
    d
i                     @   sZ   d dl Z d dlmZmZ d dlmZ d dlmZ eddgdZe	dd	efd
dZ
dS )    N)	APIRouterHTTPException)openweathermap_api_key)WeatherRequestz/goalskill-sales/api/weatherWeather)prefixtags requestc              
      s8  t }zzt 4 I d H d}d}| j| j|ddd}|j||dI d H }| }|jdkr<ddd	W  d   I d H  W S |d
 d d }t|d d d}|d
 d d }	d|	 d}
| d| |
d	W  d   I d H  W S 1 I d H svw   Y  W d S  t	y } zt
d|  ddd	W  Y d }~S d }~ww )Nz/https://api.openweathermap.org/data/2.5/weathermetricja)latlonappidunitslang)params   zWeather Errorr	   )weather_texticon_urlweatherr   descriptionmaintemp   iconz"https://openweathermap.org/img/wn/z@2x.pngu   ℃ zWeather API Error: )r   httpxAsyncClientr   r   getjsonstatus_coderound	Exceptionprint)r
   API_KEYclienturlr   respdataweather_descr   	icon_coder   e r,   </home/air/goalskill_sales/back/app/routers/weather_router.pyget_current_weather   s:   
4r.   )r   fastapir   r   app.core.configr   app.schemas.weather_schemasr   routerpostr.   r,   r,   r,   r-   <module>   s    