jschwab21 commited on
Commit
4efe8e3
·
verified ·
1 Parent(s): 53550de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -49,13 +49,16 @@ class CustomTheme(Base):
49
 
50
  custom_theme = CustomTheme()
51
 
52
- def save_uploaded_file(uploaded_file):
53
- import os
 
54
  upload_dir = "uploaded_videos"
55
  os.makedirs(upload_dir, exist_ok=True)
56
- file_path = os.path.join(upload_dir, uploaded_file.name)
 
 
57
  with open(file_path, "wb") as f:
58
- f.write(uploaded_file.file.read()) # Write the content to the new file
59
  return file_path
60
 
61
  def display_results(video_file):
 
49
 
50
  custom_theme = CustomTheme()
51
 
52
+ from datetime import datetime
53
+
54
+ def save_uploaded_file(uploaded_bytes):
55
  upload_dir = "uploaded_videos"
56
  os.makedirs(upload_dir, exist_ok=True)
57
+ # Generate a unique filename using timestamp to avoid overwriting files
58
+ file_name = f"uploaded_video_{datetime.now().strftime('%Y%m%d%H%M%S')}.mp4"
59
+ file_path = os.path.join(upload_dir, file_name)
60
  with open(file_path, "wb") as f:
61
+ f.write(uploaded_bytes)
62
  return file_path
63
 
64
  def display_results(video_file):