TianyiMoe/backend/randpic/random_picture.py

16 lines
430 B
Python

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