Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -76,6 +76,32 @@ def get_uploads(secret):
|
|
| 76 |
else:
|
| 77 |
return '''<p style="color:red;font-size:20px;text-align:center;font-weight:bold;">Invalid Secret Key</p>'''
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
js = '''
|
| 80 |
function test() {
|
| 81 |
document.title = "File Sharing System";
|
|
@@ -151,6 +177,13 @@ with gr.Blocks(theme=theme, js=js, css=css) as demo:
|
|
| 151 |
uploads = gr.Markdown(label="Uploads")
|
| 152 |
get_upload_button = gr.Button("Get Uploads", variant='primary')
|
| 153 |
get_upload_button.click(fn=get_uploads, inputs=secret_key, outputs=uploads)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
gr.Markdown('''> To know more read the docs at: [Documentation](https://huggingface.co/spaces/abhicodes/file-sharing-system/blob/main/README.md)''')
|
| 156 |
|
|
|
|
| 76 |
else:
|
| 77 |
return '''<p style="color:red;font-size:20px;text-align:center;font-weight:bold;">Invalid Secret Key</p>'''
|
| 78 |
|
| 79 |
+
def get_notes(secret):
|
| 80 |
+
if secret == os.environ.get('SECRET_KEY'):
|
| 81 |
+
result = references_collection.find_one({"_id": ObjectId('6655fe4ca6913aa201819e72')}, {"_id": 0})
|
| 82 |
+
if result:
|
| 83 |
+
gr.Info("Recieved uploaded files")
|
| 84 |
+
return result['notes']
|
| 85 |
+
else:
|
| 86 |
+
gr.Info("No result found")
|
| 87 |
+
return '''No result found'''
|
| 88 |
+
else:
|
| 89 |
+
gr.Warning("Invalid Secret Key")
|
| 90 |
+
return '''Invalid Secret Key'''
|
| 91 |
+
|
| 92 |
+
def save_notes(note, secret):
|
| 93 |
+
if secret == os.environ.get('SECRET_KEY'):
|
| 94 |
+
result = references_collection.update_one({"_id": ObjectId('6655fe4ca6913aa201819e72')}, {"$set": {"notes": note}})
|
| 95 |
+
if result:
|
| 96 |
+
gr.Info("Notes saved successfully.")
|
| 97 |
+
return note
|
| 98 |
+
else:
|
| 99 |
+
gr.Info("No result found")
|
| 100 |
+
return '''No result found'''
|
| 101 |
+
else:
|
| 102 |
+
gr.Warning("Invalid Secret Key")
|
| 103 |
+
return note
|
| 104 |
+
|
| 105 |
js = '''
|
| 106 |
function test() {
|
| 107 |
document.title = "File Sharing System";
|
|
|
|
| 177 |
uploads = gr.Markdown(label="Uploads")
|
| 178 |
get_upload_button = gr.Button("Get Uploads", variant='primary')
|
| 179 |
get_upload_button.click(fn=get_uploads, inputs=secret_key, outputs=uploads)
|
| 180 |
+
|
| 181 |
+
notes = gr.TextArea(label="📝 Share Notes", placeholder="Enter your notes...")
|
| 182 |
+
with gr.Row():
|
| 183 |
+
get_notes_button = gr.Button("Get Notes", variant="primary")
|
| 184 |
+
get_notes_button.click(fn=get_notes, inputs=secret_key, outputs=notes)
|
| 185 |
+
save_notes_button = gr.Button("Save", variant="primary")
|
| 186 |
+
save_notes_button.click(fn=save_notes, inputs=[notes,secret_key], outputs=notes)
|
| 187 |
|
| 188 |
gr.Markdown('''> To know more read the docs at: [Documentation](https://huggingface.co/spaces/abhicodes/file-sharing-system/blob/main/README.md)''')
|
| 189 |
|