bookwyrm-mastodon/bookwyrm/vviews.py

20 lines
600 B
Python
Raw Normal View History

2020-02-22 17:02:03 -05:00
''' views for pages you can go to in the application '''
2020-01-25 18:25:19 -05:00
from django.template.response import TemplateResponse
2020-01-28 14:45:27 -05:00
2020-02-22 17:02:03 -05:00
2020-03-13 20:57:36 -04:00
def is_api_request(request):
''' check whether a request is asking for html or data '''
return 'json' in request.headers.get('Accept') or \
request.path[-5:] == '.json'
def server_error_page(request):
''' 500 errors '''
return TemplateResponse(
request, 'error.html', {'title': 'Oops!'}, status=500)
def not_found_page(request, _):
''' 404s '''
return TemplateResponse(
request, 'notfound.html', {'title': 'Not found'}, status=404)