Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
def save_uploaded_file(uploaded_file):
|
| 5 |
+
try:
|
| 6 |
+
with open(os.path.join("uploads", uploaded_file.name), "wb") as f:
|
| 7 |
+
f.write(uploaded_file.getbuffer())
|
| 8 |
+
return True
|
| 9 |
+
except:
|
| 10 |
+
return False
|
| 11 |
+
|
| 12 |
+
st.set_page_config(page_title="Video Uploader for Hugging Face Spaces")
|
| 13 |
+
|
| 14 |
+
st.title("Video Uploader for Hugging Face Spaces")
|
| 15 |
+
|
| 16 |
+
uploaded_file = st.file_uploader("Choose a video file", type=['mp4', 'mkv', 'avi', 'mov'])
|
| 17 |
+
if uploaded_file is not None:
|
| 18 |
+
if save_uploaded_file(uploaded_file):
|
| 19 |
+
st.success("File successfully uploaded")
|
| 20 |
+
else:
|
| 21 |
+
st.error("Error uploading file")
|
| 22 |
+
|
| 23 |
+
# Display the HTML content
|
| 24 |
+
with open("index.html", "r") as f:
|
| 25 |
+
html_content = f.read()
|
| 26 |
+
st.components.v1.html(html_content, height=600)
|