File tree Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ def index(self):
10
10
<html>
11
11
<body>
12
12
<center>
13
- <h1>Star Wars: Revenge of the Sith (III) Stream</h1>
14
13
<video width="640" height="360" controls>
15
14
<source src="/stream" type="video/mp4">
16
15
Your browser does not support the video tag. Use Chrome for best results.
@@ -83,9 +82,3 @@ def generator(start=0, end=None):
83
82
84
83
# The WSGI entry point Gunicorn will look for
85
84
wsgi_app = app .wsgi_app
86
-
87
- if __name__ == "__main__" :
88
- # Optional: run a simple server (no partial-content).
89
- # For partial-content, run via: gunicorn app:wsgi_app
90
- app .run (port = 8080 )
91
-
Original file line number Diff line number Diff line change
1
+ import os
2
+ from MicroPie import Server
3
+
4
+ VIDEO_PATH = "path/to/your/video.mp4"
5
+
6
+ class VideoStreamer (Server ):
7
+ def index (self ):
8
+ """Serve the HTML page with a video player."""
9
+ return '''
10
+ <html>
11
+ <body>
12
+ <center>
13
+ <video width="640" height="360" controls>
14
+ <source src="/stream" type="video/mp4">
15
+ Your browser does not support the video tag.
16
+ </video>
17
+ </center>
18
+ </body>
19
+ </html>
20
+ '''
21
+
22
+ def stream (self ):
23
+ """Stream the video file in chunks."""
24
+ def generator ():
25
+ chunk_size = 1024 * 1024 # 1MB chunks
26
+ try :
27
+ with open (VIDEO_PATH , 'rb' ) as video :
28
+ while chunk := video .read (chunk_size ):
29
+ yield chunk
30
+ except FileNotFoundError :
31
+ yield b"Video file not found."
32
+
33
+ return generator ()
34
+
35
+ app = VideoStreamer ()
36
+ wsgi_app = app .wsgi_app
You can’t perform that action at this time.
0 commit comments