Add Pillow dependency and implement screenshot functionality in web server
This commit is contained in:
parent
7e612c1af7
commit
84d65cb505
@ -5,3 +5,4 @@ python-dotenv
|
|||||||
# libraries to control mouse+keyboard+see screen
|
# libraries to control mouse+keyboard+see screen
|
||||||
pyautogui
|
pyautogui
|
||||||
pynput
|
pynput
|
||||||
|
Pillow
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
import os, ai.processor
|
import os, ai.processor
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
import io
|
||||||
|
from PIL import ImageGrab
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
@ -36,6 +38,14 @@ class WebServerApp:
|
|||||||
img_data = img_file.read()
|
img_data = img_file.read()
|
||||||
else:
|
else:
|
||||||
img_data = None
|
img_data = None
|
||||||
|
else:
|
||||||
|
if 'host_screenshot' in data:
|
||||||
|
# take a screenshot right here
|
||||||
|
# capture the full screen
|
||||||
|
screenshot_img = ImageGrab.grab()
|
||||||
|
buf = io.BytesIO()
|
||||||
|
screenshot_img.save(buf, format='PNG')
|
||||||
|
img_data = buf.getvalue()
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
# Convert image data to base64 if provided
|
# Convert image data to base64 if provided
|
||||||
|
Loading…
Reference in New Issue
Block a user