Created
August 24, 2022 10:30
-
-
Save wrouesnel/d26f2b54a936be0860a89a855b3bbc84 to your computer and use it in GitHub Desktop.
Python relative requests session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from furl import furl | |
class RelativeSession(requests.Session): | |
def __init__(self, base_url): | |
super(RelativeSession, self).__init__() | |
self.__base_url = furl(base_url) | |
def request(self, method, url, **kwargs): | |
url = str(self.__base_url / url) | |
return super(RelativeSession, self).request(method, url, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment