Show a file.

    The actual content of the file is rendered by _handle_content.
481383
def _serve_file(self, abspath, params):
    
    relpath = os.path.relpath(abspath, self._root)
    breadcrumbs = self._create_breadcrumbs(relpath)
    link_path = urlunparse(['', '', relpath, '', urlencode(params), ''])
    args = self._default_template_args('file.html')
    args.update({'root_parent': os.path.dirname(self._root),
                 'breadcrumbs': breadcrumbs,
                 'link_path': link_path})
    content = self._renderer.render_name('base.html', args).encode("utf-8")
    self._send_content(content, 'text/html')
963114
function handleFile(name, file, options, cache, callback) {
	var cachedData;
	if(!options || !options.settings || options.settings['view cache'] !== false) {
		cachedData = cache && cache.get(file);
	}
	if (!cachedData) {
		loadFile(file, function(err, fileData) {
			if (err) {
				return callback(err);
			}

			var partials;
			try {
				partials = findPartials(fileData);
			} catch (err) {
				return callback(err);
			}

			var data = {
				name: name,
				data: fileData,
				partials: partials
			};
			if (cache) {
				cache.set(file, data);
			}
			return callback(null, data);
		});
	}
	else {
		return callback(null, cachedData);
	}
}
556305
def serve_file(path_to_file: str,
               offered_filename: str = None,
               content_type: str = None,
               as_attachment: bool = False,
               as_inline: bool = False) -> HttpResponseBase:
    
    # http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files  # noqa
    # https://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-browser-to-treat-the-response-as-a-file-attachment  # noqa
    # https://djangosnippets.org/snippets/365/
    if offered_filename is None:
        offered_filename = os.path.basename(path_to_file) or ''
    if settings.XSENDFILE:
        response = HttpResponse()
        response['X-Sendfile'] = smart_str(path_to_file)
        content_length = os.path.getsize(path_to_file)
    else:
        response = FileResponse(open(path_to_file, mode='rb'))
        content_length = None
    add_http_headers_for_attachment(response,
                                    offered_filename=offered_filename,
                                    content_type=content_type,
                                    as_attachment=as_attachment,
                                    as_inline=as_inline,
                                    content_length=content_length)
    return response
134427
def serve_buffer(data: bytes,
                 offered_filename: str = None,
                 content_type: str = None,
                 as_attachment: bool = True,
                 as_inline: bool = False) -> HttpResponse:
    
    response = HttpResponse(data)
    add_http_headers_for_attachment(response,
                                    offered_filename=offered_filename,
                                    content_type=content_type,
                                    as_attachment=as_attachment,
                                    as_inline=as_inline,
                                    content_length=len(data))
    return response
892243
public function renderInOutput()
  {
    if ($this->initialized) {
      $finfo = finfo_open(FILEINFO_MIME_TYPE);
      $infos = finfo_file($finfo, static::getStorePath().$this->accessKey);

      header('Content-Type: '.$infos);
      header('Expires: 0');
      header('Cache-Control: must-revalidate');
      header('Pragma: public');
      header('Content-Length: ' . filesize(static::getStorePath().$this->accessKey));
      readfile(static::getStorePath().$this->accessKey);
    } else {
      throw new \Exception('Connexion securisée au fichier non vérifiée.');
    }
  }
1315956
def file_show(context, id, file_id):
    
    result = component.file_get(context, id=id, file_id=file_id)
    utils.format_output(result, context.format)
157070
def render_text(path, cp):
    

    # define filename and slug from path
    filename = os.path.basename(path)
    slug = filename.replace('.', '_')

    # initializations
    content = None

    # read file as a string
    with codecs.open(path, 'r', encoding='utf-8', errors='replace') as fp:
        content = fp.read()

    # replace all the escaped characters
    content = unescape(content, unescape_table)

    # render template
    template_dir = pycbc.results.__path__[0] + '/templates/files'
    env = Environment(loader=FileSystemLoader(template_dir))
    env.globals.update(abs=abs)
    env.globals.update(path_exists=os.path.exists)
    template = env.get_template('file_pre.html')
    context = {'filename' : filename,
               'slug'     : slug,
               'cp'       : cp,
               'content'  : content}
    output = template.render(context)

    return output
1053281
def show(filename=None, *args, **kwargs):
        
        if filename is None:
            plt.show(*args, **kwargs)
        else:
            plt.savefig(filename, *args, **kwargs)
1180951
public function viewFileManager()
    {
        $this->setFileFileManager();
        $this->setAccessFileManager();
        $this->setDataMessagesFileManager();

        $this->setData('access', $this->data_access);
        $this->setData('command', $this->data_command);
        $this->setData('selected', $this->data_selected);
        $this->setData('tabs', $this->getTabsFileManager());
        $this->setData('actions', $this->getActionsFileManager());
        $this->setData('process_selected', $this->isQuery('selected'));

        $this->submitFileManager();
        $this->setDataContendFileManager();

        $rendered = $this->render('file_manager|filemanager', $this->data);

        if ($this->isQuery('output')) {
            $this->response->outputHtml($rendered);
        }

        $this->setJsFileManager();
        $this->setCssFileManager();

        $this->setTitleFileManager();
        $this->setBreadcrumbFileManager();

        $this->setData('rendered_filemanager', $rendered);
        $this->outputViewFileManager();
    }
1347319
def render_erb
      renderer = ERB.new(template_content, nil, '-')
      renderer.filename = @template_file
      renderer.result(binding)
    end
1308638
def file_show(context, id, file_id):
    
    result = dci_file.get(context, id=file_id)
    utils.format_output(result, context.format)
75987
def file_for(content)
      "snp_#{template_name}".tap do |file_name|
        File.open(file_name, "w+") { |f| f.write(content) }
      end
    end
439785
def write(content)
      handle = File.open(@path, 'w')

      handle.write(content)
      handle.close
    end
1208723
public function showFile($path)
    {
        // We need to clean the output buffer before showing the file
        ob_end_clean();
        ob_start();

        $type = \File::mimeType($path);

        return response()->file($path, ['Content-Type' => $type]);
    }
1010435
def read
      handle  = File.open(@path, 'r')
      content = handle.read

      handle.close

      content
    end
891372
function (callback) {
					const str = files[file].contents.toString();
					if (!handlebarsMatcher.test(str)) {
						return callback();
					}

					render(str, metadata, function (err, res) {
						if (err) return callback(err);
						files[file].contents = Buffer.from(res);
						callback();
					});
				}
1161367
def render_to_response(self, context=False):
        """"""
        f = self.openfile()
        wrapper = FileWrapper(f)
        response = HttpResponse(wrapper, content_type=self.content_type())
        self.headers(response)
        return response