BraydenMoore commited on
Commit
03208bc
1 Parent(s): 91cc8c1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -3
main.py CHANGED
@@ -27,6 +27,16 @@ def latlon_to_pixel(loc):
27
  x = ((longitude+180)/360)
28
  return x*100, y*100
29
 
 
 
 
 
 
 
 
 
 
 
30
  @app.route('/')
31
  def index():
32
  feed = random.randint(0, len(feed_dict) - 1)
@@ -38,10 +48,9 @@ def index():
38
  timezone = pytz.timezone(info['timezone'])
39
  time = dt.datetime.now(timezone)
40
  loc = info['loc']
41
- print(info)
42
  X, Y = latlon_to_pixel(info['loc'])
43
- print(url)
44
- return render_template('index.html', name=name, url=url, info=info, time=time, ip=ip, org=org, loc=loc, X=X, Y=Y)
45
 
46
  if __name__ == '__main__':
47
  app.run(host='0.0.0.0', port='7860')
 
27
  x = ((longitude+180)/360)
28
  return x*100, y*100
29
 
30
+ @app.route('/video/<path:url>')
31
+ def video(url):
32
+ req = requests.get(f"http://{url}", stream=True)
33
+
34
+ def generate():
35
+ for chunk in req.iter_content(chunk_size=1024):
36
+ yield chunk
37
+
38
+ return Response(stream_with_context(generate()), content_type=req.headers['content-type'])
39
+
40
  @app.route('/')
41
  def index():
42
  feed = random.randint(0, len(feed_dict) - 1)
 
48
  timezone = pytz.timezone(info['timezone'])
49
  time = dt.datetime.now(timezone)
50
  loc = info['loc']
 
51
  X, Y = latlon_to_pixel(info['loc'])
52
+ proxied_url = f"/video/{ip}/mjpg/video.mjpg" # Replace with your specific path
53
+ return render_template('index.html', name=name, url=proxied_url, info=info, time=time, ip=ip, org=org, loc=loc, X=X, Y=Y)
54
 
55
  if __name__ == '__main__':
56
  app.run(host='0.0.0.0', port='7860')