MCPcopy Create free account
hub / github.com/requests-cache/requests-cache / main

Function main

examples/basic_patching.py:16–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15
16def main():
17 # The real request will only be made once; afterward, the cached response is used
18 for _ in range(5):
19 response = requests.get('https://httpbin.org/get')
20
21 # This is more obvious when calling a slow endpoint
22 for _ in range(5):
23 response = requests.get('https://httpbin.org/delay/2')
24
25 # Caching can be disabled if we want to get a fresh page and not cache it
26 with requests_cache.disabled():
27 print(requests.get('https://httpbin.org/ip').text)
28
29 # Get some debugging info about the cache
30 print(requests_cache.get_cache())
31 print('Cached URLS:')
32 print('\n'.join(requests_cache.get_cache().urls()))
33
34 # Uninstall to remove caching from all requests functions
35 requests_cache.uninstall_cache()
36
37
38if __name__ == '__main__':

Callers 1

basic_patching.pyFile · 0.70

Calls 2

getMethod · 0.80
urlsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…