Spaces:
No application file
No application file
File size: 1,662 Bytes
84054cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import streamlit as st
import os
from initiate import process_pdf # Assuming this function is implemented in the `initiate` module
# Streamlit Admin App
st.title("Admin: PDF and Video Processor")
# File Upload Section
st.header("Upload Files")
# PDF Upload
uploaded_pdf = st.file_uploader("Upload a PDF", type=["pdf"])
# Video Upload
uploaded_videos = st.file_uploader(
"Upload Videos (multiple allowed)", type=["mp4"], accept_multiple_files=True
)
# Output Folder for Uploaded Files
upload_folder = "uploads"
os.makedirs(upload_folder, exist_ok=True)
# Save Uploaded Files
pdf_path = None
video_paths = []
if uploaded_pdf:
pdf_path = os.path.join(upload_folder, uploaded_pdf.name)
with open(pdf_path, "wb") as f:
f.write(uploaded_pdf.read())
st.success(f"Uploaded PDF: {uploaded_pdf.name}")
if uploaded_videos:
for video in uploaded_videos:
video_path = os.path.join(upload_folder, video.name)
with open(video_path, "wb") as f:
f.write(video.read())
video_paths.append(video_path)
st.success(f"Uploaded {len(uploaded_videos)} videos")
# Process Button
if st.button("Start Processing"):
if not pdf_path:
st.error("Please upload a PDF before starting the process.")
elif not video_paths:
st.error("Please upload at least one video before starting the process.")
else:
try:
# Call the `process_pdf` function
process_pdf(pdf_path, video_paths) # video_paths is a list
st.success("Processing completed successfully!")
except Exception as e:
st.error(f"An error occurred during processing: {e}")
|