HTTP Helpers
HTTP Helpers module contains helper functions for making http, requests, url validations etc. Its name contains "HTTP" but it might contain helper functions for other protocols. I named it like this because http seems cool in a module name .
URL
First, the class validates the URL at intialization.
from backend_dev_utils import URLurl = URL("http://////example.com")backend_dev_utils.http_helpers.exceptions.InvalidURLError: Invalid URL: http://////example.com
Then you can change its scheme, netloc, path, params and fragment:
from backend_dev_utils import URLurl = URL("http://www.example.com")url.with_scheme("https")https://www.example.comurl.with_netloc("example2.net")https://example2.neturl.with_path("/hello/world")https://example2.net/hello/worldurl.with_query_param(key="hello", value="world")https://example2.net/hello/world?hello=worldurl.delete_query_param("hello")https://example2.net/hello/worldurl.with_fragment("hello")https://example2.net/hello/world#hello