Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
|
4 |
+
# Title and description
|
5 |
+
st.title("Document Processing App")
|
6 |
+
st.write("Upload a PDF, Excel, Word, PNG, JPG, or JPEG file to process it.")
|
7 |
+
|
8 |
+
# Define the path for the new folder
|
9 |
+
folder_path = "/workspace/olmocr/new_folder"
|
10 |
+
|
11 |
+
# Create the folder if it doesn't exist
|
12 |
+
if not os.path.exists(folder_path):
|
13 |
+
os.makedirs(folder_path)
|
14 |
+
st.write(f"Folder created: {folder_path}")
|
15 |
+
else:
|
16 |
+
st.write(f"Folder already exists: {folder_path}")
|
17 |
+
|
18 |
+
# File uploader
|
19 |
+
uploaded_file = st.sidebar.file_uploader("Choose a file", type=["pdf", "xls", "xlsx", "doc", "docx", "png", "jpg", "jpeg"])
|
20 |
+
|
21 |
+
if uploaded_file is not None:
|
22 |
+
# Save the uploaded file to the new folder
|
23 |
+
file_path = os.path.join(folder_path, uploaded_file.name)
|
24 |
+
with open(file_path, "wb") as f:
|
25 |
+
f.write(uploaded_file.getbuffer())
|
26 |
+
|
27 |
+
st.write(f"File saved to: {file_path}")
|