Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /gradio-app_gradio /demo /browserstate /run.py
| import random | |
| import string | |
| import gradio as gr | |
| import time | |
| with gr.Blocks() as demo: | |
| gr.Markdown("Your Username and Password will get saved in the browser's local storage. " | |
| "If you refresh the page, the values will be retained.") | |
| username = gr.Textbox(label="Username") | |
| password = gr.Textbox(label="Password", type="password") | |
| btn = gr.Button("Generate Randomly") | |
| local_storage = gr.BrowserState(["", ""]) | |
| saved_message = gr.Markdown("✅ Saved to local storage", visible=False) | |
| def generate_randomly(): | |
| u = "".join(random.choices(string.ascii_letters + string.digits, k=10)) | |
| p = "".join(random.choices(string.ascii_letters + string.digits, k=10)) | |
| return u, p | |
| def load_from_local_storage(saved_values): | |
| print("loading from local storage", saved_values) | |
| return saved_values[0], saved_values[1] | |
| def save_to_local_storage(username, password): | |
| return [username, password] | |
| def show_saved_message(): | |
| timestamp = time.strftime("%I:%M:%S %p") | |
| return gr.Markdown( | |
| f"✅ Saved to local storage at {timestamp}", | |
| visible=True | |
| ) | |
| demo.launch() | |
Xet Storage Details
- Size:
- 1.46 kB
- Xet hash:
- ca5097eeca584e1c8bf66eb9a79d7bd2fa27d404fbe26d4667a07910bfef2a1f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.