hyperion/api/geo.py
async def api_postcode(request):
    """
    Gets data from a postcode.
    :param request: The aiohttp request.
    """
    postcode: Optional[str] = request.match_info.get('postcode', None)

    try:
        coroutine = get_postcode_random() if postcode == "random" else get_postcode(postcode)
        postcode: Optional[Postcode] = await coroutine
    except CachingError as e:
        return web.HTTPInternalServerError(body=e.status)
    except CircuitBreakerError as e:
        pass
    else:
        if postcode is not None:
            return str_json_response(postcode.serialize())
        else:
            return web.HTTPNotFound(body="Invalid Postcode")
async def api_postcode(request):
    """
    Gets data from a postcode.
    :param request: The aiohttp request.
    """
    postcode: Optional[str] = request.match_info.get('postcode', None)

    try:
        coroutine = get_postcode_random() if postcode == "random" else get_postcode(postcode)
        postcode: Optional[Postcode] = await coroutine
    except CachingError as e:
        return web.HTTPInternalServerError(body=e.status)
    except CircuitBreakerError as e:
        pass
    else:
        if postcode is not None:
            return str_json_response(postcode.serialize())
        else:
            return web.HTTPNotFound(body="Invalid Postcode")
async def api_postcode ( request ) : postcode : Optional [ str ] = request . match_info . get ( 'postcode' , None ) try : coroutine = get_postcode_random ( ) if postcode == "random" else get_postcode ( postcode ) postcode : Optional [ Postcode ] = await coroutine except CachingError as e : return web . HTTPInternalServerError ( body = e . status ) except CircuitBreakerError as e : pass else : if postcode is not None : return str_json_response ( postcode . serialize ( ) ) else : return web . HTTPNotFound ( body = "Invalid Postcode" )
Gets data from a postcode.
    :param request: The aiohttp request.
Gets data from a postcode . : param request : The aiohttp request .