From 50df600edb52a122ae50afdc461bf1c631bd6fb1 Mon Sep 17 00:00:00 2001
From: s47700 <s47700@bht-berlin.de>
Date: Sat, 23 Mar 2024 16:25:50 +0100
Subject: [PATCH] Upload New File

---
 .../foward image attempts/fo2ward_image.py    | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 api attempts/foward image attempts/fo2ward_image.py

diff --git a/api attempts/foward image attempts/fo2ward_image.py b/api attempts/foward image attempts/fo2ward_image.py
new file mode 100644
index 0000000..124ef60
--- /dev/null
+++ b/api attempts/foward image attempts/fo2ward_image.py	
@@ -0,0 +1,20 @@
+import requests
+from PIL import Image
+from io import BytesIO
+# Fetch camera image from OctoPrint
+def fetch_camera_image():
+    url =  "http://192.168.0.205/webcam/?action=stream"
+    response = requests.get(url, timeout=10)
+    print(f"Response size: {len(response.content)} bytes") # Check the size of the response
+    return response.content
+
+def display_image(image_data):
+    try:
+        image = Image.open(BytesIO(image_data))
+        image.show()
+    except Exception as e:
+        print(f"Error displaying image: {e}") # Log any errors
+
+if __name__ == "__main__":
+    image_data = fetch_camera_image()
+    display_image(image_data)
-- 
GitLab