engrharis commited on
Commit
0742a4e
·
verified ·
1 Parent(s): fb2e9b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -19
app.py CHANGED
@@ -1,27 +1,25 @@
1
  import streamlit as st
2
- import base64
3
- import numpy as np
4
- import matplotlib.pyplot as plt
5
- from matplotlib.patches import Polygon, Circle
6
-
7
- def set_background(video_path):
8
- """Sets the background of the Streamlit app to a video."""
9
- with open(video_path, "rb") as video_file:
10
  video_bytes = video_file.read()
11
- video_base64 = base64.b64encode(video_bytes).decode("utf-8")
 
 
12
  video_html = f"""
13
- <style>
14
- .main {{
15
- background-image: url("data:video/mp4;base64,{video_base64}");
16
- background-size: cover;
17
- }}
18
- </style>
19
- """
 
 
 
 
20
  st.markdown(video_html, unsafe_allow_html=True)
21
 
22
- # Set the background *before* any other Streamlit elements
23
- set_background("numbers moving background.mp4") # Replace with your video path
24
-
25
  # --- Triangle Calculation and Plotting Functions ---
26
  def calculate_distance(x1, y1, x2, y2):
27
  return np.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
 
1
  import streamlit as st
2
+ def set_background_video():
3
+ video_path = 'numbers moving background.mp4'
4
+ with open(video_path, 'rb') as video_file:
 
 
 
 
 
5
  video_bytes = video_file.read()
6
+ video_base64 = base64.b64encode(video_bytes).decode('utf-8')
7
+
8
+ # Adjust the video HTML
9
  video_html = f"""
10
+ <video
11
+ style="position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%; width: auto; height: auto; z-index: -1;"
12
+ preload="auto"
13
+ autoplay
14
+ loop
15
+ muted
16
+ >
17
+ <source src="data:video/mp4;base64,{video_base64}" type="video/mp4">
18
+ Your browser does not support the video tag.
19
+ </video>
20
+ """
21
  st.markdown(video_html, unsafe_allow_html=True)
22
 
 
 
 
23
  # --- Triangle Calculation and Plotting Functions ---
24
  def calculate_distance(x1, y1, x2, y2):
25
  return np.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)