19 lines
589 B
Python
19 lines
589 B
Python
import json
|
|
import random
|
|
from .models import Picture
|
|
|
|
pics=Picture.objects.order_by("?")
|
|
|
|
def get_random_picture_url():
|
|
selected_pic=pics[0]
|
|
return "https://cdn.clf3.org/tianyi-random/"+selected_pic.name+".webp"
|
|
def get_random_picture_meta():
|
|
selected_pic=pics[0]
|
|
return {
|
|
"name":selected_pic.name,
|
|
"url":"https://cdn.clf3.org/tianyi-random/"+selected_pic.name+".webp",
|
|
"description":selected_pic.description,
|
|
"author":selected_pic.author,
|
|
"author_url":selected_pic.author_url,
|
|
"original_url":selected_pic.original_url
|
|
} |