Just for completeness (and in case anyone is interested), this should work -
In a server module :
@anvil.server.http_endpoint("/tools/:v")
def tools(v, **params):
if v=="myip":
# Return it or store it somewhere.
return anvil.server.request.remote_address
From your client (form) :
import anvil.http
...
myip=anvil.http.request("https://<yourappid>.anvilapp.net/_/api/tools/myip")
print(repr(a.get_bytes()))