How to get HA Url from python script

Hello is it possible to get ha_url from hass in python script?
Or somehow to get it from secrets?