Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import time
|
|
|
4 |
from helper import (
|
5 |
create_user, verify_user, get_user_files, upload_file, download_file,
|
6 |
delete_file, empty_vault, is_admin, get_all_accounts, delete_account,
|
@@ -31,12 +32,12 @@ def login(username, password):
|
|
31 |
if check_inactivity():
|
32 |
return gr.update(visible=True), gr.update(visible=False), "You have been logged out due to inactivity."
|
33 |
|
34 |
-
if is_account_locked(username):
|
35 |
-
return gr.update(visible=True), gr.update(visible=False), "Account is locked. Please try again later."
|
36 |
-
|
37 |
if is_rate_limited(username):
|
38 |
return gr.update(visible=True), gr.update(visible=False), "Too many login attempts. Please try again later."
|
39 |
|
|
|
|
|
|
|
40 |
if verify_user(username, password):
|
41 |
current_user = username
|
42 |
update_activity()
|
@@ -71,8 +72,8 @@ def upload(files):
|
|
71 |
if file.size > MAX_FILE_SIZE:
|
72 |
results.append(f"File {file.name} exceeds the 5GB limit.")
|
73 |
else:
|
74 |
-
|
75 |
-
result = upload_file(current_user, file.name,
|
76 |
results.append(result)
|
77 |
|
78 |
update_activity()
|
@@ -96,9 +97,9 @@ def download(filename):
|
|
96 |
if not current_user:
|
97 |
return None
|
98 |
|
99 |
-
|
100 |
-
if
|
101 |
-
decrypted_content = decrypt_file(filename,
|
102 |
update_activity()
|
103 |
return decrypted_content
|
104 |
else:
|
@@ -146,8 +147,8 @@ def admin_delete_account(username):
|
|
146 |
return result
|
147 |
|
148 |
# Gradio interface
|
149 |
-
with gr.Blocks() as app:
|
150 |
-
gr.HTML('<img src="file/logo.svg" alt="Grimvault Logo"
|
151 |
|
152 |
with gr.Tab("Login"):
|
153 |
login_username = gr.Textbox(label="Username")
|
@@ -157,7 +158,7 @@ with gr.Blocks() as app:
|
|
157 |
login_message = gr.Textbox(label="Message", interactive=False)
|
158 |
|
159 |
with gr.Tab("Dashboard", visible=False) as dashboard:
|
160 |
-
gr.HTML('<img src="file/logo.svg" alt="Grimvault Logo"
|
161 |
upload_button = gr.File(label="Upload File(s)", file_count="multiple")
|
162 |
files_table = gr.Dataframe(label="Your Files", headers=["File", "Size"])
|
163 |
refresh_button = gr.Button("Refresh Files")
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import time
|
4 |
+
from functools import partial
|
5 |
from helper import (
|
6 |
create_user, verify_user, get_user_files, upload_file, download_file,
|
7 |
delete_file, empty_vault, is_admin, get_all_accounts, delete_account,
|
|
|
32 |
if check_inactivity():
|
33 |
return gr.update(visible=True), gr.update(visible=False), "You have been logged out due to inactivity."
|
34 |
|
|
|
|
|
|
|
35 |
if is_rate_limited(username):
|
36 |
return gr.update(visible=True), gr.update(visible=False), "Too many login attempts. Please try again later."
|
37 |
|
38 |
+
if is_account_locked(username):
|
39 |
+
return gr.update(visible=True), gr.update(visible=False), "Account is locked. Please try again later."
|
40 |
+
|
41 |
if verify_user(username, password):
|
42 |
current_user = username
|
43 |
update_activity()
|
|
|
72 |
if file.size > MAX_FILE_SIZE:
|
73 |
results.append(f"File {file.name} exceeds the 5GB limit.")
|
74 |
else:
|
75 |
+
encrypted_file = encrypt_file(file.name, file.read())
|
76 |
+
result = upload_file(current_user, file.name, encrypted_file)
|
77 |
results.append(result)
|
78 |
|
79 |
update_activity()
|
|
|
97 |
if not current_user:
|
98 |
return None
|
99 |
|
100 |
+
file_content = download_file(current_user, filename)
|
101 |
+
if file_content:
|
102 |
+
decrypted_content = decrypt_file(filename, file_content)
|
103 |
update_activity()
|
104 |
return decrypted_content
|
105 |
else:
|
|
|
147 |
return result
|
148 |
|
149 |
# Gradio interface
|
150 |
+
with gr.Blocks(css="styles.css") as app:
|
151 |
+
gr.HTML('<img src="file/logo.svg" alt="Grimvault Logo" class="logo">')
|
152 |
|
153 |
with gr.Tab("Login"):
|
154 |
login_username = gr.Textbox(label="Username")
|
|
|
158 |
login_message = gr.Textbox(label="Message", interactive=False)
|
159 |
|
160 |
with gr.Tab("Dashboard", visible=False) as dashboard:
|
161 |
+
gr.HTML('<img src="file/logo.svg" alt="Grimvault Logo" class="logo-small">')
|
162 |
upload_button = gr.File(label="Upload File(s)", file_count="multiple")
|
163 |
files_table = gr.Dataframe(label="Your Files", headers=["File", "Size"])
|
164 |
refresh_button = gr.Button("Refresh Files")
|