From 0c47170a32495960bc88a9214377c9ed2b8ff422 Mon Sep 17 00:00:00 2001 From: ClF3 Date: Tue, 30 Apr 2024 13:09:31 +0800 Subject: [PATCH] changed random api --- backend/randpic/random_picture.py | 4 ++-- backend/randpic/views.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/randpic/random_picture.py b/backend/randpic/random_picture.py index 3d3186a..45dfd6e 100644 --- a/backend/randpic/random_picture.py +++ b/backend/randpic/random_picture.py @@ -4,5 +4,5 @@ from .models import Picture pics=Picture.objects.order_by("?") -def get_random_picture(): - return pics[0].name+".webp" \ No newline at end of file +def get_random_picture_url(): + return "https://cdn.clf3.org/tianyi-random/"+pics[0].name+".webp" \ No newline at end of file diff --git a/backend/randpic/views.py b/backend/randpic/views.py index daef3fb..608b1fe 100644 --- a/backend/randpic/views.py +++ b/backend/randpic/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, redirect from django.http import HttpResponse -from .random_picture import get_random_picture +from .random_picture import get_random_picture_url # Create your views here. def index(request): - return redirect("https://cdn.clf3.org/tianyi-random/{}".format(get_random_picture())) \ No newline at end of file + return redirect(get_random_picture_url()) \ No newline at end of file