Page.on_url_request#

Page.on_url_request(func, display_return_value=False)[source]#

Sets a function that will be called when the user types the URL in a browser or when a request is sent to the URL. You can view it as the view_func in Flask. It might have limited functionality compared to calling Python functions from HTML, but it is the best for retrieving data from HTTP requests.

Parameters:
  • func (Callable) – The function that will be called when a request is sent to the URL.

  • display_return_value (bool, default=False) – If True, the browser will display the return value of the function when the URL is loaded. If False, the return value will be ignored.