diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-06-17 12:54:41 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-06-17 13:59:47 -0500 |
commit | 59fc52e4a9d426da651d6fe93336ac8b2585c9b8 (patch) | |
tree | a8c581f5af5ce0e9c2e6dbf8d1ab993a6d763a42 /examples | |
parent | d9e246a2c8c25da0d7626df708cfcbf9725c5f8e (diff) | |
download | requests-cache-59fc52e4a9d426da651d6fe93336ac8b2585c9b8.tar.gz |
Related doc updates
Diffstat (limited to 'examples')
-rw-r--r-- | examples/README.md | 3 | ||||
-rwxr-xr-x | examples/basic_sessions.py | 2 | ||||
-rwxr-xr-x | examples/expiration.py | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/external_config.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/time_machine_backtesting.py | 0 | ||||
-rwxr-xr-x | examples/url_patterns.py | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | examples/vcr.py | 0 |
7 files changed, 13 insertions, 8 deletions
diff --git a/examples/README.md b/examples/README.md index 09b35e7..3c0c1f4 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,3 +1,4 @@ # Requests-Cache Examples This folder contains some complete examples that demonstrate the main features of requests-cache. -These are also viewable on [readthedocs](https://requests-cache.readthedocs.io/en/stable/examples.html). +See the [Examples](https://requests-cache.readthedocs.io/en/stable/examples.html) section of the +docs for a summary. diff --git a/examples/basic_sessions.py b/examples/basic_sessions.py index 21c746e..7c448b4 100755 --- a/examples/basic_sessions.py +++ b/examples/basic_sessions.py @@ -29,7 +29,7 @@ def main(): print('\n'.join(session.cache.urls())) -if __name__ == "__main__": +if __name__ == '__main__': t = time.time() main() print('Elapsed: %.3f seconds' % (time.time() - t)) diff --git a/examples/expiration.py b/examples/expiration.py index 942b198..6ca4c5b 100755 --- a/examples/expiration.py +++ b/examples/expiration.py @@ -38,7 +38,7 @@ def main(): assert not response.from_cache -if __name__ == "__main__": +if __name__ == '__main__': t = time.perf_counter() main() print('Elapsed: %.3f seconds' % (time.perf_counter() - t)) diff --git a/examples/external_config.py b/examples/external_config.py index 0ab6508..0ab6508 100644..100755 --- a/examples/external_config.py +++ b/examples/external_config.py diff --git a/examples/time_machine_backtesting.py b/examples/time_machine_backtesting.py index 4ec9c42..4ec9c42 100644..100755 --- a/examples/time_machine_backtesting.py +++ b/examples/time_machine_backtesting.py diff --git a/examples/url_patterns.py b/examples/url_patterns.py index d61f3c1..e4f0f31 100755 --- a/examples/url_patterns.py +++ b/examples/url_patterns.py @@ -16,12 +16,12 @@ urls_expire_after = { urls = [ 'https://httpbin.org/get', # Will expire in an hour 'https://httpbin.org/image/jpeg', # Will expire in a week - 'https://www.fillmurray.com/460/300', # Will never expire + 'https://www.fillmurray.com/460/300', # Will never expire 'https://via.placeholder.com/350x150', # Will not be cached ] -def main(): +def send_requests(): session = CachedSession( cache_name='example_cache', expire_after=default_expire_after, @@ -39,11 +39,15 @@ def _expires_str(response): return response.expires.isoformat() -if __name__ == "__main__": - original_responses = main() - cached_responses = main() +def main(): + send_requests() + cached_responses = send_requests() for response in cached_responses: print( f'{response.url:40} From cache: {response.from_cache:}' f'\tExpires: {_expires_str(response)}' ) + + +if __name__ == '__main__': + main() diff --git a/examples/vcr.py b/examples/vcr.py index 94e4fdb..94e4fdb 100644..100755 --- a/examples/vcr.py +++ b/examples/vcr.py |