def server_error(self, request, error): """Provide stack trace as HttpResponse for debugging error is stack trace and exception message string return response code 500 """ request.setResponseCode(500) # context is error string context = {'error': error} return render(request, '500.html', context)
def path_not_found(self, request): """Provide 404 message and registered routes for debugging display collection of valid paths that have registered views return response code 404 """ request.setResponseCode(404) # context is collection of valid paths context = {'paths': self.paths} return render(request, '404.html', context)
def viewa(request): """Example view for template""" context = {'view_name': 'landing', 'penguin_type': 'grand penguin'} return miniweb.render(request, 'landing.html', context)
def viewc(request): """Example view for template""" context = {'first_parameter': 'name', 'second_parameter': 'grand penguin'} return miniweb.render(request, 'secondary.html', context)
def view_exception(request): """Example view for template""" # this view is used to demonstrate 500 server error with traceback on a broken view context = {'first_paramete': 'name', 'second_parameter': 'grand penguin'} return miniweb.render(request, 'secondary.html', context)