changed random api

This commit is contained in:
ClF3 2024-04-30 13:09:31 +08:00
parent 6239b8e3e5
commit 0c47170a32
2 changed files with 4 additions and 4 deletions

View File

@ -4,5 +4,5 @@ from .models import Picture
pics=Picture.objects.order_by("?") pics=Picture.objects.order_by("?")
def get_random_picture(): def get_random_picture_url():
return pics[0].name+".webp" return "https://cdn.clf3.org/tianyi-random/"+pics[0].name+".webp"

View File

@ -1,6 +1,6 @@
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.http import HttpResponse from django.http import HttpResponse
from .random_picture import get_random_picture from .random_picture import get_random_picture_url
# Create your views here. # Create your views here.
def index(request): def index(request):
return redirect("https://cdn.clf3.org/tianyi-random/{}".format(get_random_picture())) return redirect(get_random_picture_url())