Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
|
|
| 1 |
from ftplib import FTP
|
| 2 |
|
|
|
|
| 3 |
host = "cph.v4one.co.uk"
|
| 4 |
username = "yash.sharma"
|
| 5 |
-
password = "8x]EnG/Z%DXvcjt[%<;S"
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
ftp = FTP(host)
|
| 10 |
-
ftp.login(user=username, passwd=password)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from ftplib import FTP
|
| 3 |
|
| 4 |
+
# FTP server credentials
|
| 5 |
host = "cph.v4one.co.uk"
|
| 6 |
username = "yash.sharma"
|
| 7 |
+
password = "8x]EnG/Z%DXvcjt[%<;S" # Replace with your actual password
|
| 8 |
|
| 9 |
+
# Streamlit UI for FTP connection
|
| 10 |
+
st.title("FTP File Browser")
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
st.sidebar.header("FTP Connection Details")
|
| 13 |
+
host_input = st.sidebar.text_input("Host", host)
|
| 14 |
+
username_input = st.sidebar.text_input("Username", username)
|
| 15 |
+
password_input = st.sidebar.text_input("Password", type="password", value=password)
|
| 16 |
|
| 17 |
+
if st.sidebar.button("🔄 Connect & List Files"):
|
| 18 |
+
try:
|
| 19 |
+
# Connect to FTP server
|
| 20 |
+
ftp = FTP(host_input)
|
| 21 |
+
ftp.login(user=username_input, passwd=password_input)
|
| 22 |
|
| 23 |
+
# List files in the root directory
|
| 24 |
+
files = []
|
| 25 |
+
ftp.retrlines('LIST', lambda x: files.append(x.split()[-1])) # Get filenames from LIST command
|
| 26 |
+
|
| 27 |
+
ftp.quit()
|
| 28 |
+
|
| 29 |
+
# Show files in dropdown
|
| 30 |
+
if files:
|
| 31 |
+
selected_file = st.selectbox("Select a file", files)
|
| 32 |
+
st.write(f"File selected: {selected_file}")
|
| 33 |
+
else:
|
| 34 |
+
st.warning("No files found on the FTP server.")
|
| 35 |
+
|
| 36 |
+
except Exception as e:
|
| 37 |
+
st.error(f"Error: {e}")
|