binary1ne commited on
Commit
093ab0d
·
verified ·
1 Parent(s): e9518e5

Update webui_with_vnc.py

Browse files
Files changed (1) hide show
  1. webui_with_vnc.py +27 -9
webui_with_vnc.py CHANGED
@@ -1,15 +1,33 @@
1
- import gradio as gr
2
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- def greet(name):
5
- return f"Hello {name}!"
6
 
7
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
8
 
9
- # Serve noVNC files inside /web-vnc
10
- novnc_path = "/web-ui/static/novnc"
11
 
12
- if os.path.exists(novnc_path):
13
- demo.add_static_route("/web-vnc", novnc_path)
14
 
15
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
1
+ from dotenv import load_dotenv
2
  import os
3
+ import argparse
4
+ import gradio as gr
5
+ from src.webui.interface import theme_map, create_ui
6
+
7
+ load_dotenv()
8
+
9
+ def main():
10
+ parser = argparse.ArgumentParser(description="Gradio WebUI for Browser Agent")
11
+ parser.add_argument("--ip", type=str, default=os.getenv("HOST", "0.0.0.0"), help="IP address to bind to")
12
+ parser.add_argument("--port", type=int, default=int(os.getenv("PORT", "7860")), help="Port to listen on")
13
+ parser.add_argument("--theme", type=str, default=os.getenv("THEME", "Ocean"), choices=theme_map.keys(), help="Theme to use for the UI")
14
+ args = parser.parse_args()
15
+
16
+ # Existing UI
17
+ base_ui = create_ui(theme_name=args.theme)
18
+
19
+ # Combine into single Gradio app
20
+ with gr.Blocks(theme=args.theme) as demo:
21
+ gr.Markdown("# 🌐 Browser Agent Web-UI")
22
 
23
+ with gr.Tab("Main App"):
24
+ base_ui.render()
25
 
26
+ with gr.Tab("Web VNC"):
27
+ gr.HTML('<iframe src="http://localhost:6080/vnc.html" width="100%" height="800"></iframe>')
28
 
29
+ demo.queue().launch(server_name=args.ip, server_port=args.port)
 
30
 
 
 
31
 
32
+ if __name__ == "__main__":
33
+ main()