wmdjt commited on
Commit
ce518f0
·
verified ·
1 Parent(s): ba4e9dc

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -60
app.py DELETED
@@ -1,60 +0,0 @@
1
- import subprocess
2
- import threading
3
- import time
4
- import gradio as gr
5
- import os
6
-
7
- def check_windows_status():
8
- """检查 Windows 容器状态"""
9
- try:
10
- result = subprocess.run(["pgrep", "-f", "qemu"], capture_output=True, text=True)
11
- return "运行中" if result.returncode == 0 else "已停止"
12
- except:
13
- return "状态未知"
14
-
15
- def start_windows():
16
- """启动 Windows 容器"""
17
- def run_windows():
18
- # 启动 QEMU 虚拟机
19
- subprocess.run([
20
- "qemu-system-x86_64",
21
- "-accel", "tcg",
22
- "-m", "4G",
23
- "-drive", "file=/data/windows.img,format=qcow2",
24
- "-vnc", ":0",
25
- "-monitor", "stdio"
26
- ])
27
-
28
- thread = threading.Thread(target=run_windows)
29
- thread.daemon = True
30
- thread.start()
31
- return "Windows 启动中..."
32
-
33
- def create_gradio_interface():
34
- """创建 Gradio 界面"""
35
- with gr.Blocks(title="Windows in Docker") as demo:
36
- gr.Markdown("# 🪟 Windows Docker 容器")
37
- gr.Markdown("在 Hugging Face Spaces 中运行的 Windows 容器")
38
-
39
- with gr.Row():
40
- status = gr.Textbox(label="容器状态", value=check_windows_status, every=30)
41
- start_btn = gr.Button("启动 Windows")
42
-
43
- with gr.Row():
44
- vnc_viewer = gr.HTML("""
45
- <div style="text-align: center;">
46
- <p>VNC 查看器将在这里显示</p>
47
- <p>使用 VNC 客户端连接: your-space.hf.space</p>
48
- </div>
49
- """)
50
-
51
- start_btn.click(
52
- fn=start_windows,
53
- outputs=status
54
- )
55
-
56
- return demo
57
-
58
- if __name__ == "__main__":
59
- demo = create_gradio_interface()
60
- demo.launch(server_name="0.0.0.0", server_port=8006)