Spaces:
Sleeping
Sleeping
Create App.py
Browse files
App.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import psutil
|
| 3 |
+
import datetime
|
| 4 |
+
|
| 5 |
+
# βββββββββββββββββββββββββββββββ
|
| 6 |
+
# LocalDesk Web Prototype
|
| 7 |
+
# Author: Justin Strange
|
| 8 |
+
# License: Commons Clause + MIT
|
| 9 |
+
# βββββββββββββββββββββββββββββββ
|
| 10 |
+
|
| 11 |
+
clipboard_history = []
|
| 12 |
+
|
| 13 |
+
def add_to_clipboard(text):
|
| 14 |
+
"""Simulate a clipboard manager"""
|
| 15 |
+
if text.strip():
|
| 16 |
+
clipboard_history.append(f"{datetime.datetime.now():%H:%M:%S} {text}")
|
| 17 |
+
return "\n".join(clipboard_history[-10:])
|
| 18 |
+
|
| 19 |
+
def get_system_stats():
|
| 20 |
+
"""Return simple system info"""
|
| 21 |
+
cpu = psutil.cpu_percent(interval=0.2)
|
| 22 |
+
mem = psutil.virtual_memory()
|
| 23 |
+
return f"CPU Usage: {cpu}%\nMemory Usage: {mem.percent}%"
|
| 24 |
+
|
| 25 |
+
def write_note(title, content):
|
| 26 |
+
"""Pretend-save a note"""
|
| 27 |
+
if not title:
|
| 28 |
+
title = f"Untitled-{datetime.datetime.now():%H%M%S}"
|
| 29 |
+
return f"ποΈ Saved: {title}\n\n{content}"
|
| 30 |
+
|
| 31 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="green")) as demo:
|
| 32 |
+
gr.Markdown(
|
| 33 |
+
"# π₯οΈ LocalDesk (Web Prototype)\n"
|
| 34 |
+
"### Created by Justin Strange\n"
|
| 35 |
+
"Offline-first utility suite prototype built with Gradio"
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
with gr.Tab("Clipboard Manager"):
|
| 39 |
+
clip_in = gr.Textbox(label="Copy text here")
|
| 40 |
+
clip_out = gr.Textbox(label="Clipboard History", lines=10)
|
| 41 |
+
clip_btn = gr.Button("Add to Clipboard")
|
| 42 |
+
clip_btn.click(add_to_clipboard, inputs=clip_in, outputs=clip_out)
|
| 43 |
+
|
| 44 |
+
with gr.Tab("Notes"):
|
| 45 |
+
note_title = gr.Textbox(label="Note Title")
|
| 46 |
+
note_body = gr.Textbox(label="Note Content", lines=8)
|
| 47 |
+
note_out = gr.Textbox(label="Saved Note")
|
| 48 |
+
save_btn = gr.Button("Save Note")
|
| 49 |
+
save_btn.click(write_note, inputs=[note_title, note_body], outputs=note_out)
|
| 50 |
+
|
| 51 |
+
with gr.Tab("System Monitor"):
|
| 52 |
+
sys_box = gr.Textbox(label="System Stats", lines=3)
|
| 53 |
+
refresh = gr.Button("Refresh")
|
| 54 |
+
refresh.click(get_system_stats, outputs=sys_box)
|
| 55 |
+
|
| 56 |
+
demo.launch()
|