Files
jumpserver/apps/jumpserver/error_views.py
2019-03-05 19:47:14 +08:00

21 lines
627 B
Python

# -*- coding: utf-8 -*-
#
from django.shortcuts import render
from django.http import JsonResponse
def handler404(request, *args, **argv):
if request.content_type.find('application/json') > -1:
response = JsonResponse({'error': 'Not found'}, status=404)
else:
response = render(request, '404.html', status=404)
return response
def handler500(request, *args, **argv):
if request.content_type.find('application/json') > -1:
response = JsonResponse({'error': 'Server internal error'}, status=500)
else:
response = render(request, '500.html', status=500)
return response