Spaces:
Running
Running
Changed UI
Browse files
app.py
CHANGED
@@ -31,7 +31,7 @@ def upload(file):
|
|
31 |
folder_contents_dict = get_folder_contents_dict(root_directory)
|
32 |
print(folder_contents_dict)
|
33 |
|
34 |
-
base_url = "https://abhicodes-file-
|
35 |
|
36 |
urls = [f"{base_url}/{folder}/{file}" for folder, files in folder_contents_dict.items() for file in files]
|
37 |
|
@@ -73,21 +73,38 @@ def get_uploads(secret):
|
|
73 |
else:
|
74 |
return {"error": "Unauthorized"}
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
gr.Markdown('''<h1 style="text-align:center;">File Storing and Sharing System</h1>''')
|
78 |
-
gr.
|
79 |
-
|
80 |
-
|
|
|
|
|
81 |
with gr.Row():
|
82 |
with gr.Column():
|
83 |
-
gr.Markdown('''<h1 style="text-align:center;">Uploader</h1>''')
|
84 |
input = gr.File(label="Input", file_count="multiple")
|
85 |
input.upload(fn=upload, inputs=input)
|
86 |
with gr.Column():
|
87 |
-
gr.Markdown('''<h1 style="text-align:center;">Downloader</h1>''')
|
88 |
-
secret_key = gr.Text(placeholder="Enter your Secret Key")
|
89 |
uploads = gr.Markdown(label="Uploads")
|
90 |
get_upload_button = gr.Button("Get Uploads", variant='primary')
|
91 |
get_upload_button.click(fn=get_uploads, inputs=secret_key, outputs=uploads)
|
92 |
|
|
|
|
|
|
|
93 |
demo.launch(debug=True)
|
|
|
31 |
folder_contents_dict = get_folder_contents_dict(root_directory)
|
32 |
print(folder_contents_dict)
|
33 |
|
34 |
+
base_url = "https://abhicodes-file-uploader-component.hf.space/file=/tmp/gradio"
|
35 |
|
36 |
urls = [f"{base_url}/{folder}/{file}" for folder, files in folder_contents_dict.items() for file in files]
|
37 |
|
|
|
73 |
else:
|
74 |
return {"error": "Unauthorized"}
|
75 |
|
76 |
+
js = '''
|
77 |
+
function test() {
|
78 |
+
console.log("Test");
|
79 |
+
document.title = "File Sharing System";
|
80 |
+
var link = document.createElement('link');
|
81 |
+
link.type = 'image/x-icon';
|
82 |
+
link.rel = 'shortcut icon';
|
83 |
+
link.href = 'https://cdn3d.iconscout.com/3d/premium/thumb/cloud-storage-5402862-4521475.png';
|
84 |
+
document.getElementsByTagName('head')[0].appendChild(link);
|
85 |
+
}
|
86 |
+
'''
|
87 |
+
|
88 |
+
with gr.Blocks(theme=theme, js=js) as demo:
|
89 |
gr.Markdown('''<h1 style="text-align:center;">File Storing and Sharing System</h1>''')
|
90 |
+
with gr.Column():
|
91 |
+
gr.Markdown('''<div style="display:flex;justify-content:center;align-items:center"><img src="https://cdn3d.iconscout.com/3d/premium/thumb/cloud-storage-5402862-4521475.png" alt="logo" width="100"/>
|
92 |
+
<div style="width:100px;"></div>
|
93 |
+
This project is a file storing and sharing system built using Gradio for the front-end interface and MongoDB for the back-end database. The system allows users to upload files, which are then stored and managed within a specified directory. URLs for accessing these files are generated and stored in a MongoDB collection, making it easy to share and access the uploaded files.''')
|
94 |
+
|
95 |
with gr.Row():
|
96 |
with gr.Column():
|
97 |
+
gr.Markdown('''<h1 style="text-align:center;display:flex;justify-content:center;align-items:center"><img src="https://i.ibb.co/FB6tMdT/upload.png" alt="upload" width="50">Uploader</h1>''')
|
98 |
input = gr.File(label="Input", file_count="multiple")
|
99 |
input.upload(fn=upload, inputs=input)
|
100 |
with gr.Column():
|
101 |
+
gr.Markdown('''<h1 style="text-align:center;display:flex;justify-content:center;align-items:center"><img src="https://i.ibb.co/K9Bq3j7/download.png" alt="download" width="50">Downloader</h1>''')
|
102 |
+
secret_key = gr.Text(placeholder="Enter your Secret Key", type="password", autofocus=True)
|
103 |
uploads = gr.Markdown(label="Uploads")
|
104 |
get_upload_button = gr.Button("Get Uploads", variant='primary')
|
105 |
get_upload_button.click(fn=get_uploads, inputs=secret_key, outputs=uploads)
|
106 |
|
107 |
+
gr.Markdown('''> To know more read the docs at: [Documentation](https://huggingface.co/spaces/abhicodes/file-sharing-system/blob/main/README.md)''')
|
108 |
+
|
109 |
+
|
110 |
demo.launch(debug=True)
|