def read_file_or_default(filepath, default=b''):
    """
    Helper function.

    Read the file from the server file system. If the file is not available,
    write a file with some default content and return that content.

    :param filepath: is the path to the file to read. If the file does not
        exist, the default value is written.
    :param default: is the byte string used if the file does not exist.
    """
    try:
        with open(filepath, 'rb') as fin:
            return fin.read()
    except FileNotFoundError:
        with open(filepath, 'wb') as fout:
            fout.write(default)
        # Try again
        try:
            with open(filepath, 'rb') as fin:
                return fin.read()
        except FileNotFoundError:
            # On the second fail, return an error
            return ('failed to read server file', 500)