ManojGowda commited on
Commit
5669389
·
verified ·
1 Parent(s): 354af9b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # The local URL of your ESP32 camera stream
4
+ esp_cam_url = "http://eyecam.local/mjpeg/1"
5
+
6
+ def create_stream_html(url):
7
+ """Creates an HTML snippet to display the MJPEG stream."""
8
+ # MJPEG streams can be displayed directly in an <img> tag.
9
+ # We embed this in an iframe for better isolation and layout control.
10
+ # The 'rel="nofollow"' is good practice for external links.
11
+ iframe_html = f"""
12
+ <iframe srcdoc='<img src="{url}" width="100%" height="auto" rel="nofollow"/>'
13
+ width="640"
14
+ height="480"
15
+ frameborder="0"
16
+ allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
17
+ allowfullscreen>
18
+ </iframe>
19
+ """
20
+ return iframe_html
21
+
22
+ with gr.Blocks() as demo:
23
+ gr.Markdown("# ESP32 Cam Live Stream")
24
+ gr.Markdown(
25
+ "This interface attempts to display a live stream from an ESP32 camera on the local network. "
26
+ "**Note:** This will only work if your computer can directly access the camera's URL."
27
+ )
28
+
29
+ # Using the gr.HTML component to render the iframe
30
+ gr.HTML(create_stream_html(esp_cam_url))
31
+
32
+ if __name__ == "__main__":
33
+ # To run this app locally and make it accessible on your network
34
+ demo.launch(server_name="0.0.0.0")
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio