<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def handle_purge(environ, start_response):
 """ Handle a PURGE request. """

    from utils import is_valid_security, get_cached_files
    from settings import DEBUG
    server = environ['SERVER_NAME']
    try:
        request_uri = get_path(environ)
        path_and_query = request_uri.lstrip("/")
        query_string = environ.get('QUERY_STRING', '')
        if is_valid_security('PURGE', query_string):
            cached_files = get_cached_files(path_and_query, server)
            for i in cached_files:
                try:
                    os.remove(i)
                except OSError as e:
                    return do_500(environ, start_response, e.message)
            start_response("204 No Content", [])
            return []
        else:
            return do_405(environ, start_response)
    except Http404 as e:
        return do_404(environ, start_response, e.message, DEBUG)