Spaces:
Sleeping
Sleeping
Tihsrah-CD
commited on
Commit
•
5a43d63
1
Parent(s):
3c0e9ce
updated
Browse files
app.py
CHANGED
@@ -2,41 +2,34 @@ import streamlit as st
|
|
2 |
import requests
|
3 |
import os
|
4 |
|
5 |
-
def
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
if st.button('Download File'):
|
11 |
-
response = requests.get(download_link, allow_redirects=True)
|
12 |
-
if response.status_code == 200:
|
13 |
-
filename = "downloaded_file.ext" # You can customize the filename
|
14 |
-
with open(filename, 'wb') as file:
|
15 |
-
file.write(response.content)
|
16 |
-
st.success(f"File downloaded successfully and saved as {filename}")
|
17 |
-
else:
|
18 |
-
st.error(f"Failed to download the file. Status code: {response.status_code}")
|
19 |
-
|
20 |
-
if __name__ == '__main__':
|
21 |
-
main()
|
22 |
-
import streamlit as st
|
23 |
-
import requests
|
24 |
-
import os
|
25 |
|
26 |
def main():
|
27 |
st.title('Download File from OneDrive')
|
28 |
|
|
|
29 |
download_link = "https://upesstd-my.sharepoint.com/:u:/g/personal/500082340_stu_upes_ac_in/EYwRTq9dcTJHppgydRR-8BMBYY2BehA6jxri5rKehcSZig?e=fjAYDf"
|
|
|
|
|
|
|
30 |
|
31 |
-
if
|
32 |
-
|
33 |
-
if
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
|
41 |
if __name__ == '__main__':
|
42 |
main()
|
|
|
2 |
import requests
|
3 |
import os
|
4 |
|
5 |
+
def find_file(filename, directory):
|
6 |
+
for root, dirs, files in os.walk(directory):
|
7 |
+
if filename in files:
|
8 |
+
return os.path.join(root, filename)
|
9 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def main():
|
12 |
st.title('Download File from OneDrive')
|
13 |
|
14 |
+
search_filename = "english_vocab.pkl"
|
15 |
download_link = "https://upesstd-my.sharepoint.com/:u:/g/personal/500082340_stu_upes_ac_in/EYwRTq9dcTJHppgydRR-8BMBYY2BehA6jxri5rKehcSZig?e=fjAYDf"
|
16 |
+
save_filename = "classifer.joblib"
|
17 |
+
|
18 |
+
found_path = find_file(search_filename, os.getcwd())
|
19 |
|
20 |
+
if found_path:
|
21 |
+
st.success(f"Found {search_filename} at {found_path}")
|
22 |
+
if st.button('Download File'):
|
23 |
+
response = requests.get(download_link, allow_redirects=True)
|
24 |
+
if response.status_code == 200:
|
25 |
+
save_path = os.path.join(os.path.dirname(found_path), save_filename)
|
26 |
+
with open(save_path, 'wb') as file:
|
27 |
+
file.write(response.content)
|
28 |
+
st.success(f"File downloaded successfully and saved as {save_path}")
|
29 |
+
else:
|
30 |
+
st.error(f"Failed to download the file. Status code: {response.status_code}")
|
31 |
+
else:
|
32 |
+
st.error(f"File {search_filename} not found in the current directory or subdirectories.")
|
33 |
|
34 |
if __name__ == '__main__':
|
35 |
main()
|