add django_code_new just in case before removing it

This commit is contained in:
2024-10-29 23:15:37 +00:00
parent a4a704305a
commit 1cb49c3127
40 changed files with 413 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+68
View File
@@ -0,0 +1,68 @@
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('<h1>Hello Simpsons!</h1>')
#<h1>href="{{ STATIC_URL }}/files/somefile</h1>)
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("<h1>Hello download!</h1><h1><a href='{{ MEDIA_URL }}{{ django_file.relative_path }}'>{{ django_file.name }}</a></h1><h1>bye download!</h1>")
# 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('<h1>Hello !</h1>')
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))
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
@@ -0,0 +1 @@
<h1>Hello template!</h1>
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+8
View File
@@ -0,0 +1,8 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render
def hello(request):
return HttpResponse('<h1>Hello Django!</h1>')