File size: 1,351 Bytes
6237b12
f756937
 
6237b12
5a43d63
 
 
 
 
6237b12
f756937
 
 
5a43d63
f756937
5a43d63
 
 
f756937
5a43d63
 
 
 
 
 
 
 
 
 
 
 
 
6237b12
 
 
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
import streamlit as st
import requests
import os

def find_file(filename, directory):
    for root, dirs, files in os.walk(directory):
        if filename in files:
            return os.path.join(root, filename)
    return None

def main():
    st.title('Download File from OneDrive')

    search_filename = "english_vocab.pkl"
    download_link = "https://upesstd-my.sharepoint.com/:u:/g/personal/500082340_stu_upes_ac_in/EYwRTq9dcTJHppgydRR-8BMBYY2BehA6jxri5rKehcSZig?e=fjAYDf"
    save_filename = "classifer.joblib"

    found_path = find_file(search_filename, os.getcwd())
    
    if found_path:
        st.success(f"Found {search_filename} at {found_path}")
        if st.button('Download File'):
            response = requests.get(download_link, allow_redirects=True)
            if response.status_code == 200:
                save_path = os.path.join(os.path.dirname(found_path), save_filename)
                with open(save_path, 'wb') as file:
                    file.write(response.content)
                st.success(f"File downloaded successfully and saved as {save_path}")
            else:
                st.error(f"Failed to download the file. Status code: {response.status_code}")
    else:
        st.error(f"File {search_filename} not found in the current directory or subdirectories.")

if __name__ == '__main__':
    main()