Код, который у меня есть, снимает скриншоты и сохраняет его в папке с мультимедиа, поэтому я хочу напечатать снимки на своей странице html, но это вызывает у меня проблемы, я думаю, что мне очень не хватает.
это мой python код, который делает скриншоты
from django.http import HttpResponse
import time,random,pyautogui
from django.db import models
import sys,os
from shots.models import pictures
from shots.forms.forms import DocumentForm
from django.conf import settings
def button(request):
return render(request,'index.html')
def output(request):
while True:
myScreenshot = pyautogui.screenshot()
name = random.randrange(1,1000)
full_name = str(name) + ".jpg"
filepath = settings.MEDIA_ROOT + '\shots'
full_path = filepath + full_name
saver = myScreenshot.save(full_path)
# generate a random time between 120 and 300 sec
random_time = random.randrange(3,6)
# wait between 120 and 300 seconds (or between 2 and 5 minutes)
time.sleep(random_time)
myScreenshots2 = []
myScreenshots2.append(saver)
# return (myScreenshots2)
return HttpResponse(request,'task.html',saver)
def stopshot(request):
os.system("pause")```