import json
import requests


def fetch_file_from_web(server_url, path, transform_func=json.loads):
    """Fetch file from a web server

    The default behavior is to transform the response to a json.
    """
    artifact_url = "{0}/{1}".format(server_url, path)
    r = requests.get(artifact_url)
    r.raise_for_status()
    if transform_func:
        return transform_func(r.text)
    else:
        return r.text