summaryrefslogtreecommitdiffstats
path: root/g4f/gui/webview.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-13 05:27:54 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-13 05:27:54 +0100
commitecf110e59a35ad41377b82d8d1f5f58802b66539 (patch)
treec3d9da4d4305c14fe01b3fcd77af161b7fb2a9cb /g4f/gui/webview.py
parentAdd count chars to gui, Add retry support to fix rate limit in Bing (diff)
downloadgpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.gz
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.bz2
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.lz
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.xz
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.zst
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.zip
Diffstat (limited to 'g4f/gui/webview.py')
-rw-r--r--g4f/gui/webview.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/g4f/gui/webview.py b/g4f/gui/webview.py
new file mode 100644
index 00000000..5a4263dc
--- /dev/null
+++ b/g4f/gui/webview.py
@@ -0,0 +1,24 @@
+import webview
+from functools import partial
+from platformdirs import user_config_dir
+
+from g4f.gui import run_gui
+from g4f.gui.run import gui_parser
+import g4f.version
+import g4f.debug
+
+def run_webview(host: str = "0.0.0.0", port: int = 8080, debug: bool = True):
+ webview.create_window(f"g4f - {g4f.version.utils.current_version}", f"http://{host}:{port}/")
+ if debug:
+ g4f.debug.logging = True
+ webview.start(
+ partial(run_gui, host, port),
+ private_mode=False,
+ storage_path=user_config_dir("g4f-webview"),
+ debug=debug
+ )
+
+if __name__ == "__main__":
+ parser = gui_parser()
+ args = parser.parse_args()
+ run_webview(args.host, args.port, args.debug) \ No newline at end of file