Finish
This commit is contained in:
14
short_url/views.py
Normal file
14
short_url/views.py
Normal file
@ -0,0 +1,14 @@
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from .models import ShortUrl
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def redirect_to_target(request, alias):
|
||||
short_url = get_object_or_404(ShortUrl, alias=alias)
|
||||
|
||||
response = HttpResponse(status=307)
|
||||
response['Location'] = short_url.target
|
||||
return response
|
Reference in New Issue
Block a user