Update webui_with_vnc.py
Browse files- webui_with_vnc.py +27 -9
webui_with_vnc.py
CHANGED
|
@@ -1,15 +1,33 @@
|
|
| 1 |
-
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
|
| 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 |
-
|
|
|
|
|
|
| 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()
|