🗑️ cleaning
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
2026-06-17 18:59:14 +01:00
parent 47bf1d40f9
commit 2da9e9390d
3 changed files with 28 additions and 123 deletions
+25 -7
View File
@@ -1,16 +1,12 @@
from django.shortcuts import render
import random
# Create your views here.
from django.http import HttpResponse
from django.db.models import Count
from django.shortcuts import redirect
from apps.random_simpsons.models import SimpsonsData
import random
def hello(request):
return HttpResponse('<h1>Hello Django!</h1>')
return HttpResponse('<h1>Hello Simpsons view!</h1>')
def episode_generator(request):
simpsons_data_object = SimpsonsData.objects.using('simpsons_db')
@@ -41,4 +37,26 @@ def episode_generator(request):
simpsons_data_object.filter(season=random_seasons, episode=random_episode).values('seen').update(seen=True)
return redirect(str(random_url))
return redirect(str(random_url))
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