You don’t need to make HTTP requests to build an Anvil app thanks to Anvil’s ability to call Python functions between client and server code (including code outside of Anvil). Even if you’re collaborating with a third-party, they can use the Client Uplink to safely make function calls to and from your app.
Anvil has a human-friendly Python library for making HTTP requests. This works from client and server code.
import anvil.http resp = anvil.http.request("https://api.mysite.com/foo") print("Response MIME type: " + resp.content_type)
See Making HTTP Requests for details.
You can make your server functions into HTTP endpoints using a decorator:
import anvil.server @anvil.server.http_endpoint("/users/:id") def get_user(id): ip = anvil.server.request.remote_address return "You requested user %s from IP %s" % (id, ip)
See Creating HTTP Endpoints for details.