Beispiel #1
0
    def get(self):
        # The client
        rest_client = RestClient()
        rest_client.set_endpoint(endpoint=SAMPLE_GET_ENDPOINT)
        raw_result, cached_result = rest_client.do_get()

        # Done
        self.response.write('Hello from: ' + raw_result.get('url'))
Beispiel #2
0
    def __init__(self, endpoint='de'):
        self._rest_client = RestClient()

        # The DE endpoint was randomly failing to us, and RU never worked.
        # From this option we can better control the endpoint, and the queries
        # will be automatically cached independently.
        endpoint_url = OVERPASS_ENDPOINTS.get(endpoint)
        self._rest_client.set_endpoint(endpoint=endpoint_url)

        # Set better timeout value
        self._client_settings = {'timeout': OVERPASS_REQUESTS_TIMEOUT}

        # Set local caching
        memcache_client = MemcacheLocal(root_folder='_cache_overpass')
        self._rest_client.enable_cache(
            memcache_client=memcache_client,
            memcache_namespace=OVERPASS_MEMCACHE_NAMESPACE)
Beispiel #3
0
import pprint
from restwice import RestClient

SAMPLE_GET_ENDPOINT = 'http://httpbin.org/get'

# The client
rest_client = RestClient()
rest_client.set_endpoint(endpoint=SAMPLE_GET_ENDPOINT)
raw_result, cached_result = rest_client.do_get()

# Done
pprint.pprint(raw_result)
pprint.pprint(raw_result.get('url'))
pprint.pprint(cached_result)