Rishabh Saxena commited on
Commit
9f918c2
·
1 Parent(s): 876b10b

initial code

Browse files
Files changed (3) hide show
  1. Dockerfile +24 -0
  2. app.py +43 -0
  3. requirements.txt +1 -0
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python base image
2
+ FROM python:3.9-slim
3
+
4
+ # Prevent writing .pyc files and buffer issues
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+
8
+ # Set working directory
9
+ WORKDIR /app
10
+ ENV HOME=/tmp
11
+
12
+ # Copy requirements and install them
13
+ COPY requirements.txt .
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
+
16
+ # Copy app code
17
+ COPY . .
18
+
19
+ # Expose the port Streamlit runs on
20
+ EXPOSE 7860
21
+
22
+
23
+ # Run the Streamlit app
24
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false", "--server.enableCORS=false"]
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+
4
+
5
+ os.makedirs('/tmp', exist_ok=True)
6
+ os.makedirs('/tmp/data', exist_ok=True)
7
+ st.title("📁 Document Upload & Download App")
8
+
9
+ # File uploader
10
+ uploaded_files = st.file_uploader("Upload documents", type=["pdf", "docx", "txt", "xlsx"], accept_multiple_files=True)
11
+
12
+ if uploaded_files:
13
+ for file in uploaded_files:
14
+ file_path = os.path.join('/tmp/data', file.name)
15
+ with open(file_path, "wb") as f:
16
+ f.write(file.getbuffer())
17
+ st.success(f"Saved: {file.name}")
18
+
19
+ st.markdown("---")
20
+ st.subheader("📂 Download Saved Files")
21
+
22
+ saved_files = os.listdir("/tmp/data")
23
+ print(saved_files)
24
+
25
+ print("done fetching")
26
+ if saved_files:
27
+ for filename in saved_files:
28
+ print(filename)
29
+ file_path = os.path.join('/tmp/data', filename)
30
+ print(file_path)
31
+ with open(file_path, "rb") as f:
32
+ st.download_button(
33
+ label=f"⬇️ Download {filename}",
34
+ data=f,
35
+ file_name=filename,
36
+ mime="application/octet-stream",
37
+ use_container_width=True
38
+ )
39
+ else:
40
+ st.info("No files available for download.")
41
+
42
+
43
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit