from django.apps import AppConfig from django.http import HttpResponse from django.shortcuts import render from django.shortcuts import redirect from django.core.files import File #from django.template.loader import render_to_string import time import random import mimetypes def hello(request): return HttpResponse('

Hello Simpsons!

') #

href="{{ STATIC_URL }}/files/somefile

) def download_file(request): # fill these variables with real values fl_path = '/data/download/sonarr' filename = 'The.Boys.2019.S04E05.2160p.HDR10Plus.WEBRip.6CH.x265.HEVC-PSA.mkv' # fl = open(fl_path, 'r') # mime_type, _ = mimetypes.guess_type(fl_path) # response = HttpResponse(fl, content_type=mime_type) # response['Content-Disposition'] = "attachment; filename=%s" % filename some_file = open('/data/kubernetes/Backup/nextcloud/notes/2024-07-28/Course.md', "r") django_file = File(some_file) return HttpResponse("

Hello download!

{{ django_file.name }}

bye download!

") # return response def download_mo(request,file): path_to_file = os.path.realpath(file) response = FileResponse(open(path_to_file, 'rb')) file_name = file[5:] response['Content-Disposition'] = 'inline; filename=' + file_name return response #def template(request): # rendered = render_to_string("my_template.html", {"foo": "bar"}) #return HttpResponse('

Hello !

') def simpsons(request): # simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-"; simpsons_url = "https://kisscartoon.top/episode/the-simpsons-season-"; number_of_seasons = 35 seasons_maximum_number = [13,22,24,22,22,25,25,25,25,23,22,21,22,22,22,21,22,22,20,21,23,22,22,22,22,22,22,22,21,23,22,22,22,22,18] #print(simpsons_url) random_seasons = random.randint(1, number_of_seasons) print("random seasons: "+ str(random_seasons)) #random_seasons-1 because list start at index 0 print("maximum of episode for this season: "+str(seasons_maximum_number[random_seasons-1])) random_episode = random.randint(1, seasons_maximum_number[random_seasons-1]) print("random episode: "+ str(random_episode)) final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)# print(final_url) # return HttpResponse(str(final_url)) # time.sleep(10) return redirect(str(final_url))