diff --git a/.gitignore b/.gitignore index e69de29..1a00d9b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,3 @@ +backend/randpic/__pycache__ +backend/tianyi/__pycache__ +backend/db.sqlite3 \ No newline at end of file diff --git a/backend/jsons/pics.json b/backend/jsons/pics.json new file mode 100644 index 0000000..aef642b --- /dev/null +++ b/backend/jsons/pics.json @@ -0,0 +1 @@ +["001e937058fd054d0ba1c665afcffcdf.webp", "101019411_p0.webp", "101275551_p0.webp", "101301242_p0.webp", "101698611_p0.webp", "102058620_p0.webp", "102590077_p0.webp", "102757641_p0.webp", "103172744_p0.webp", "103249146_p0.webp", "103628665_p0.webp", "103690381_p0.webp", "104085936_p0.webp", "104494653_p0.webp", "104531347_p0.webp", "104639707_p0.webp", "104710041_p0.webp", "105367918_p0.webp", "105367918_p0_2x.webp", "105502043_p0.webp", "105516712_p0.webp", "105516712_p1.webp", "105516905_p0.webp", "106230376_p0.webp", "106230376_p1.webp", "106230376_p2.webp", "106672862_p0.webp", "107112208_p0.webp", "107725669_p0.webp", "107820987_p0.webp", "108369229_p0.webp", "108512300_p0.webp", "108925833_p0.webp", "108925833_p0_2x.webp", "108925833_p1.webp", "108925833_p1_2x.webp", "108981cad1c8a7864280a6f36909c93d71cf503f.webp", "109401543_p0.webp", "109453105_p0.webp", "109570174_p0.webp", "109576082_p0.webp", "109576082_p1.webp", "109832970_p0.webp", "109838747_p0.webp", "109838747_p1.webp", "109838747_p2.webp", "109845248_p0.webp", "109845248_p0_2x.webp", "109852692_p0.webp", "109852724_p0.webp", "109884134_p0.webp", "109884134_p1.webp", "109884134_p2.webp", "109943680_p0.webp", "109949791_p0.webp", "109949791_p0_2x.webp", "110251475_p0.webp", "110256436_p0.webp", "110256436_p1.webp", "110401953_p0.webp", "110434367_p0.webp", "110863589_p0.webp", "110863589_p1.webp", "111057361_p0.webp", "111608116_p0.webp", "111795588_p0.webp", "111795588_p1.webp", "111864564_p0.webp", "111968660_p0.webp", "111968660_p0_2x.webp", "112524612_p0.webp", "112524612_p2.webp", "112707037_p0.webp", "113284561_p0.webp", "113428287_p0.webp", "113428287_p1.webp", "113930282_p0.webp", "114107856_p0.webp", "114876514_p0.webp", "114906937_p0.webp", "115615309_p0.webp", "116014965_p0.webp", "116014965_p1.webp", "116046871_p0.webp", "116202466_p0.webp", "116202466_p1.webp", "116202487_p0.webp", "116202487_p1.webp", "116202504_p0.webp", "116366754_p0.webp", "116366754_p1.webp", "116852096_p0.webp", "116982600_p0.webp", "116982600_p0_2x.webp", "117027423_p0.webp", "117027423_p1.webp", "117027423_p2.webp", "117027423_p3.webp", "117714895_p0.webp", "117714895_p1.webp", "1613119603235.webp", "1689354865427.webp", "1689354873081.webp", "1689354876703.webp", "1689354880077.webp", "1689354885162.webp", "1689354888371.webp", "1697905379738.webp", "16c302adb27d17b182d576d9217e6b9d95bd54f5.webp", "1fd5189b033b5bb5728337aa21d3d539b700bc6b.webp", "20180704044351_fmcwx.webp", "20180712185917_sTcEH.webp", "20180728223235_uFrHh.webp", "2982576.webp", "31990190_p0.webp", "36422839_p0.webp", "38178304_p0.webp", "4612b46555a043777e6fa8310307b3766449ca2a.webp", "50593841_p0.webp", "56013793_p0.webp", "57856022_p0.webp", "57863525_p0.webp", "57878551_p0.webp", "57878551_p1.webp", "57883768_p0.webp", "58564658_p0.webp", "5ac3634a20a44623344515308f22720e0df3d732.webp", "60319461_p0.webp", "60685579_p0.webp", "61859029_p0.webp", "62828047_p1.webp", "63516179_p0.webp", "63573876_p0.webp", "63826897_p0.webp", "63828591_p0.webp", "63878551_p0.webp", "64024094_p0.webp", "64113046_p0.webp", "64113046_p1.webp", "64319132_p0.webp", "64531415_p0.webp", "645827d35a166c45e184cde70b5e73984a4348ad.webp", "64870288_p0.webp", "65427719_p0.webp", "655e589401f1ab7047.webp", "65641629_p0.webp", "65641629_p1.webp", "66455621_p0.webp", "66590750_p0.webp", "66732106_p0.webp", "67280596_p0.webp", "67714805_p0.webp", "67763040_p0.webp", "67780796_p0.webp", "67781434_p0.webp", "67795822_p0.webp", "68138907_p0.webp", "68271918_p0.webp", "68327765_p0.webp", "68327765_p1.webp", "68328195_p0.webp", "68349444_p0.webp", "68669958_p0.webp", "69071578_p0.webp", "69561668_p0.webp", "69648326_p0.webp", "69651529_p0.webp", "69652836_p0.webp", "69668543_p0.webp", "69668543_p1.webp", "69670927_p0.webp", "69720547_p0.webp", "69721365_p0.webp", "70089054_p0.webp", "70089054_p1.webp", "70089054_p2.webp", "70089054_p3.webp", "70089054_p4.webp", "70089054_p5.webp", "70141248_p0.webp", "70245687_p0.webp", "70246393_p0.webp", "70249775_p0.webp", "70249775_p1.webp", "70289781_p0.webp", "70429890_p0.webp", "70498171_p0.webp", "71069846_p0.webp", "71270875_p0.webp", "71338707_p0.webp", "71371962_p0.webp", "71885881_p0.webp", "71974898_p0.webp", "71974962_p0.webp", "72344254_p0.webp", "72980078_p0.webp", "72980078_p1.webp", "73054607_p0.webp", "73091136_p0.webp", "73091136_p1.webp", "73091136_p2.webp", "73091136_p3.webp", "73091136_p4.webp", "73091136_p5.webp", "73091136_p6.webp", "73234368_p0.webp", "73270164_p0.webp", "73535212_p0.webp", "73550673_p0.webp", "73707587_p0.webp", "73928618_p0.webp", "75091846_p0.webp", "75351261_p0.webp", "75487936_p0.webp", "75554096_p0.webp", "75554096_p10.webp", "75554096_p11.webp", "75554096_p12.webp", "75554096_p13.webp", "75554096_p14.webp", "75554096_p15.webp", "75554096_p16.webp", "75554096_p2.webp", "75554096_p21.webp", "75554096_p27.webp", "75554096_p28.webp", "75554096_p3.webp", "75554096_p30.webp", "75554096_p4.webp", "75554096_p7.webp", "75554096_p8.webp", "75554096_p9.webp", "75581429_p0.webp", "75677165_p1.webp", "75d7d00e299d8ac4fa5260125963a609a0e0e64f.webp", "76219970_p0.webp", "77321040_p0.webp", "78636981_p0.webp", "78636981_p1.webp", "78636981_p2.webp", "78636981_p3.webp", "78636981_p4.webp", "78636981_p5.webp", "78636981_p6.webp", "78636981_p7.webp", "79830694_p0.webp", "82630950_p0.webp", "82654575_p0.webp", "82720559_p0.webp", "82782742_p0.webp", "82910218_p0.webp", "82912326_p0.webp", "83303453_p0.webp", "83303453_p1.webp", "83303453_p2.webp", "83303453_p3.webp", "83303453_p4.webp", "83303453_p5.webp", "83404272_p0.webp", "83958317_p0.webp", "84115213_p0.webp", "8418c95f637ec80421b710962ed87d47c0ce2e3d.webp", "85603687_p0.webp", "86077302_p0.webp", "86077302_p1.webp", "87617434_p0.webp", "87617441_p0.webp", "8bea381f6f713d11b0aa45f0d93775e130a6faa8.webp", "90262829_p0.webp", "91186720_p0.webp", "91186720_p0_2x.webp", "91192019_p0.webp", "91206013_p0.webp", "91207991_p0.webp", "91226205_p0.webp", "91449182_p0.webp", "91787697_p0.webp", "92206613_p0.webp", "92795571_p0.webp", "92978590_p0.webp", "9323511ed21b0ef420788d12cac451da83cb3ece.webp", "94196708_p0.webp", "95681846_p0.webp", "95681846_p1.webp", "95681846_p2.webp", "95751654_p0.webp", "95913863_p0.webp", "97405169_p0.webp", "98097089_p0.webp", "98869805_p0.webp", "99283126_p0.webp", "99300489_p0.webp", "99463454_p0.webp", "99486679_p0.webp", "99491235_p0.webp", "99653563_p0.webp", "99653585_p0.webp", "99653585_p1.webp", "99666182_p0.webp", "99673477_p0.webp", "99675340_p0.webp", "99832923_p0.webp", "99986801_p0.webp", "a0565b8770812e3fb102bf38fddc53608174e9b5.webp", "be-elegant.webp", "e6b0debfd4718ce44bd73b92c8abb70d65862c64.webp", "ffb478b5f46b85899388899ad6b9b1bb9d6201dc.webp", "img-1654830365246233a166fa639265b.webp", "img-1657724365529859c99066cba07720068e.webp", "img-1665846834436d.webp", "img-1665847143640e133cfdb041a80af659.webp", "img-1665847203887c4ad7ec4c5fd67339991.webp", "img-1665847209011d8f5be8c726717f8da0e3.webp", "img-166584721445892cc13f26f395d52e6479.webp", "img-16658472187757f8f12309484dc7f691cb11252295dbc.webp", "img-16658472230292253ec163698b6e8dd6195.webp", "img-1665847226967634d747ab66847d22b9d4.webp", "img-1665847273646da1ce0f8d6f23d72477c5b.webp", "img-2786d4372734d270fcac1fa2ce2ff383.webp", "img-4cda46aeb7b3b9019a8ac1831e26c556760d0aa5e712d5e00ce4fa328690f9c1.webp", "img-d149e592343e36b3979c297427f614ff.webp", "img-f6d97a0f7492421c9a088c60f1c81b3f.webp", "NExOc1YyTFk5amhibjVrY1NuN1RxTlI3cm5DcVk1UmRBeHhPMUNHSkg3UGtWTEV4bXYvRm13PT0.webp", "tianyi-avatar.webp", "tianyi-signature-black.webp", "tianyi-signature.webp", "tianyi.webp", "yiruchujian.webp"] \ No newline at end of file diff --git a/backend/randpic/__init__.py b/backend/randpic/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/randpic/admin.py b/backend/randpic/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/randpic/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/randpic/apps.py b/backend/randpic/apps.py new file mode 100644 index 0000000..3d11847 --- /dev/null +++ b/backend/randpic/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class RandpicConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'randpic' diff --git a/backend/randpic/migrations/__init__.py b/backend/randpic/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/randpic/models.py b/backend/randpic/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/backend/randpic/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/backend/randpic/random_picture.py b/backend/randpic/random_picture.py new file mode 100644 index 0000000..84955ef --- /dev/null +++ b/backend/randpic/random_picture.py @@ -0,0 +1,7 @@ +import json +import random + +def get_random_picture(): + with open("./jsons/pics.json") as f: + pictures = json.load(f) + return random.choice(pictures) \ No newline at end of file diff --git a/backend/randpic/tests.py b/backend/randpic/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/randpic/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/randpic/urls.py b/backend/randpic/urls.py new file mode 100644 index 0000000..a9d7f56 --- /dev/null +++ b/backend/randpic/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.index, name="index"), +] \ No newline at end of file diff --git a/backend/randpic/views.py b/backend/randpic/views.py new file mode 100644 index 0000000..daef3fb --- /dev/null +++ b/backend/randpic/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render, redirect +from django.http import HttpResponse +from .random_picture import get_random_picture +# 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 diff --git a/backend/tianyi/urls.py b/backend/tianyi/urls.py index a2f9bc4..d2e9b78 100644 --- a/backend/tianyi/urls.py +++ b/backend/tianyi/urls.py @@ -14,8 +14,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include,path urlpatterns = [ path('admin/', admin.site.urls), + path('randpic/', include('randpic.urls')), ]