<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pre_flight_headers(self, request, methods):
 # type: (BaseHttpRequest, Sequence[api.Method]) -> Dict[str, str] """ Generate pre-flight headers. """

        methods = ', '.join(m.value for m in methods)
        headers = {
            'Allow': methods,
            'Cache-Control': 'no-cache, no-store'
        }

        allow_origin = self.allow_origin(request)
        if allow_origin:
            headers = dict_filter(headers, {
                'Access-Control-Allow-Origin': allow_origin,
                'Access-Control-Allow-Methods': methods,
                'Access-Control-Allow-Credentials': {True: 'true', False: 'false'}.get(self.allow_credentials),
                'Access-Control-Allow-Headers': ', '.join(self.allow_headers) if self.allow_headers else None,
                'Access-Control-Expose-Headers': ', '.join(self.expose_headers) if self.expose_headers else None,
                'Access-Control-Max-Age': str(self.max_age) if self.max_age else None,
            })

        return headers