def media_endpoint(_id):
 file_ = app.media.get(_id)
 if (file_ is None):
  return abort(404)
 if_modified_since = weak_date(request.headers.get('If-Modified-Since'))
 if (if_modified_since is not None):
  if (if_modified_since.tzinfo is None):
   if_modified_since = if_modified_since.replace(tzinfo=tz_util.utc)
  if (if_modified_since > file_.upload_date):
   return Response(status=304)
 headers = {'Last-Modified': date_to_rfc1123(file_.upload_date), 'Content-Length': file_.length}
 response = Response(file_, headers=headers, mimetype=file_.content_type, direct_passthrough=True)
 return response

def media_endpoint ( _id ) : file_ = app . media . get ( _id ) if ( file_ is None ) : return abort ( 404 ) if_modified_since = weak_date ( request . headers . get ( 'If-Modified-Since' ) ) if ( if_modified_since is not None ) : if ( if_modified_since . tzinfo is None ) : if_modified_since = if_modified_since . replace ( tzinfo = tz_util . utc ) if ( if_modified_since > file_ . upload_date ) : return Response ( status = 304 ) headers = { 'Last-Modified' : date_to_rfc1123 ( file_ . upload_date ) , 'Content-Length' : file_ . length } response = Response ( file_ , headers = headers , mimetype = file_ . content_type , direct_passthrough = True ) return response
this endpoint is active when return_media_as_url is true .