MCPcopy Index your code
hub / github.com/hugapi/hug / handle_404

Method handle_404

hug/api.py:321–342  ·  view source on GitHub ↗
(request, response, *args, **kwargs)

Source from the content-addressed store, hash-verified

319 base_url = self.base_url if base_url is None else base_url
320
321 def handle_404(request, response, *args, **kwargs):
322 url_prefix = request.forwarded_uri[:-1]
323 if request.path and request.path != "/":
324 url_prefix = request.forwarded_uri.split(request.path)[0]
325
326 to_return = OrderedDict()
327 to_return["404"] = (
328 "The API call you tried to make was not defined. "
329 "Here's a definition of the API to help you get going :)"
330 )
331 to_return["documentation"] = self.documentation(
332 base_url, self.determine_version(request, False), prefix=url_prefix
333 )
334
335 if self.output_format == hug.output_format.json:
336 response.data = hug.output_format.json(to_return, indent=4, separators=(",", ": "))
337 response.content_type = "application/json; charset=utf-8"
338 else:
339 response.data = self.output_format(to_return, request=request, response=response)
340 response.content_type = self.output_format.content_type
341
342 response.status = falcon.HTTP_NOT_FOUND
343
344 handle_404.interface = True
345 return handle_404

Callers

nothing calls this directly

Calls 3

documentationMethod · 0.95
determine_versionMethod · 0.95
output_formatMethod · 0.95

Tested by

no test coverage detected