Mimics Django's 404 handler but with a different template path.
342864
def page_not_found(request, template_name="errors/404.html"):
    
    context = {
        "STATIC_URL": settings.STATIC_URL,
        "request_path": request.path,
    }
    t = get_template(template_name)
    return HttpResponseNotFound(t.render(context, request))
309535
def slug(request, url):
    """"""
    page = None

    if url:
        for slug in url.split('/'):
            if not slug:
                continue
            try:
                page = Page.objects.get(slug=slug, parent=page)
            except Page.DoesNotExist:
                raise Http404
    else:
        try:
            page = Page.objects.get(slug='index', parent=None)
        except Page.DoesNotExist:
            return TemplateView.as_view(
                template_name='wafer/index.html')(request)

    if 'edit' in request.GET:
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return EditPage.as_view()(request, pk=page.id)

    if 'compare' in request.GET:
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return ComparePage.as_view()(request, pk=page.id)

    return ShowPage.as_view()(request, pk=page.id)
109326
function error(status, req, res, msg) {
    debug('%s %s', status, req.originalUrl);
    msg = msg || '';

    var page = generator.page$['/' + status];

    // 404 with no matching status page => redirect to home
    if (!page && status === 404) {
      if (generator.home) return res.redirect(302, '/');
      if (server.statics.defaultFile) return res.redirect(302, server.statics.defaultFile);
    }

    // avoid exposing error pages unless authorized
    if (page) {
      if (!server.isPageAuthorized || !server.isPageAuthorized(req, page)) {
        if (server.login) return server.login(req, res);
        else page = null;
      }
    }

    if (!page) return res.status(status).send(u.escape(msg));

    res.status(status).send(
      generator.renderDoc(page)
        .replace(/%s/g, u.escape(msg)) // TODO - replace with humane.js or proper template
        .replace('<body', '<body data-err-status="' + status + '"' + (msg ? ' data-err-msg="' + u.escape(msg) + '"' : ''))
    );
  }
55517
def page_not_found(request, template_name='404.html'):
    
    response = render_in_page(request, template_name)

    if response:
        return response

    template = Template(
        '<h1>Not Found</h1>'
        '<p>The requested URL {{ request_path }} was not found on this server.</p>')
    body = template.render(RequestContext(
        request, {'request_path': request.path}))
    return http.HttpResponseNotFound(body, content_type=CONTENT_TYPE)
907688
function(method, view) {
    return function (err) {
      if (err) {
        err.reason = 'Template#handle' + method + ': ' + view.path;
        return err;
      }
    };
  }
605972
function error404(req, res, templateDir) {
  sendPage(res, 404, 'Page not found', {
    template: 'error-404',
    templateDir: templateDir,
    vars: {
      message: "Sorry, but the page you requested doesn't exist."
    }
  });
}
789305
def default_match_error_handler(exc):
    
    if isinstance(exc, NotFound):
        return http.NotFound()
    elif isinstance(exc, MethodNotAllowed):
        return http.MethodNotAllowed()
    elif isinstance(exc, RequestRedirect):
        return redirect(exc.new_url)
    else:
        raise exc
263407
def render(self, template, context=None, def_name=None, subdir='templates', content_type=None, status=None, charset=None):
        ''''''
        template_adapter = self.get_template_loader(subdir).get_template(template)
        return getattr(template_adapter, 'render_to_response')(context=context, request=self.request, def_name=def_name, content_type=content_type, status=status, charset=charset)
705432
def get_data_by_slug_or_404(model, slug, kind='', **kwargs):
    """"""
    data = get_data_by_slug(model, slug, kind, **kwargs)

    if not data:
        abort(404)

    return data
282164
def fix_django_headers(meta):
	
	ret = {}
	for k, v in meta.items():
		if k.startswith("HTTP_"):
			k = k[len("HTTP_") :]
		elif k not in ("CONTENT_LENGTH", "CONTENT_TYPE"):
			# Skip CGI garbage
			continue

		ret[k.lower().replace("_", "-")] = v

	return ret
1277117
def error_404(request, exception):
    """"""
    return django.http.HttpResponseNotFound(
        d1_common.types.exceptions.NotFound(
            0,
            'Invalid API endpoint',
            # Include the regexes the URL was tested against
            # traceInformation=str(exception),
            nodeId=django.conf.settings.NODE_IDENTIFIER,
        ).serialize_to_transport(xslt_url=django.urls.base.reverse('home_xslt')),
        d1_common.const.CONTENT_TYPE_XML,
    )
713074
def documentation_404(self, base_url=None):
        """"""
        base_url = self.base_url if base_url is None else base_url

        def handle_404(request, response, *args, **kwargs):
            url_prefix = request.forwarded_uri[:-1]
            if request.path and request.path != "/":
                url_prefix = request.forwarded_uri.split(request.path)[0]

            to_return = OrderedDict()
            to_return['404'] = ("The API call you tried to make was not defined. "
                                "Here's a definition of the API to help you get going :)")
            to_return['documentation'] = self.documentation(base_url, self.determine_version(request, False),
                                                            prefix=url_prefix)

            if self.output_format == hug.output_format.json:
                response.data = hug.output_format.json(to_return, indent=4, separators=(',', ': '))
                response.content_type = 'application/json; charset=utf-8'
            else:
                response.data = self.output_format(to_return, request=request, response=response)
                response.content_type = self.output_format.content_type

            response.status = falcon.HTTP_NOT_FOUND

        handle_404.interface = True
        return handle_404
1210381
function notFound( req, res, next ) {
        var err = new Error( 'Not Found' );
        err.status = 404;

        next( err );
    }
396786
def server_error(request, template_name='500.html'):
    
    t = loader.get_template(template_name)
    return HttpResponseServerError(
        t.render(Context({'STATIC_URL': settings.STATIC_URL})))
615268
function handler(req, res) {

  var parsedUrl = url.parse(req.url)
  var callback = qs.parse(parsedUrl.query).callback
  var filename = decodeURI(parsedUrl.path.substr(1).split('?')[0])
  var basename = path.basename(filename.split('?')[0])
  var extname = path.extname(basename)
  var response = reswrap(res);
  var notfound = function() {
    response.writeHead(404, 'text').end('');
  };

  if (req.method === 'GET' && parsedUrl.pathname === '/jsonp-request') {
    if (!!exitCountdown) {
      exitCountdown.restart();
    }

    response
      .writeHead(200, 'js')
      .end(callback +'('+ R.get('stamp') +')');

    return;
  }

  var serve;
  if (/^\/template/.test(parsedUrl.pathname)) {
    serve = check(join(__dirname, '..', filename))
  } else if (/^\/node_modules/.test(parsedUrl.pathname)) {
    serve = check(join(__dirname, '..', filename))
  }
  if (serve) {
    serve.pass(function(name, type) {
      response
        .writeHead(200, extname.substr(1))
        .pipeWith(fs.createReadStream(
          path.resolve(name)
        ))
    }).fail(notfound);
    return;
  }

  if (/^\.(md|mkd|markdown|html)$/.test(extname)) {
    check(filename)
      .pass(function() {
        response
          .writeHead(200, 'html')
          .end(template.render({
            title: basename,
            highlight: R.get('highlight') || 'default',
            theme: getTheme(R.get('css')),
            width: R.get('width'),
            body: parser.parse(read(path.resolve(filename)))
          }));
      }).fail(notfound);

    return;
  }

  // Image or some other resources.
  check(filename)
    .pass(function(name) {
      response
        .writeHead(200, name)
        .pipeWith(fs.createReadStream(name));
    }).fail(notfound)
}
1290162
def clean_path_middleware(environ, start_response=None):
    ''''''
    path = environ['PATH_INFO']
    if path and '//' in path:
        url = re.sub("/+", '/', path)
        if not url.startswith('/'):
            url = '/%s' % url
        qs = environ['QUERY_STRING']
        if qs:
            url = '%s?%s' % (url, qs)
        raise HttpRedirect(url)
95351
function (err, req, res, next) {
    err = this.coerceError(err);

    if (err instanceof errors.NotFound && req.accepts('html')) {
      if (err instanceof errors.BinNotFound) {
        if (req.editor) {
          return (new BinHandler(this.sandbox)).notFound(req, res, next);
        }
      }

      return this.renderErrorPage('error', err, req, res);
    } else if (err instanceof errors.HTTPError) {
      // return this.renderError(err, req, res);
      return this.renderErrorPage(err.status, err, req, res);
    }

    if (err) {
      // console.error(err.stack);
    }

    next(err);
  }