summaryrefslogtreecommitdiffstats
path: root/g4f/gui
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-15 14:55:53 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-15 14:55:53 +0100
commitb7eee50930dbd782d7c068d1d29cd270b97bc741 (patch)
treebdaa4377a62352cf2641c67a6bc21f903b5c0ea1 /g4f/gui
parentAdd Pyinstaller support, Use curl_cffi in You provider (diff)
downloadgpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.tar
gpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.tar.gz
gpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.tar.bz2
gpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.tar.lz
gpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.tar.xz
gpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.tar.zst
gpt4free-b7eee50930dbd782d7c068d1d29cd270b97bc741.zip
Diffstat (limited to 'g4f/gui')
-rw-r--r--g4f/gui/webview.py27
-rw-r--r--g4f/gui/webview.spec45
2 files changed, 66 insertions, 6 deletions
diff --git a/g4f/gui/webview.py b/g4f/gui/webview.py
index 5a4263dc..16f143c4 100644
--- a/g4f/gui/webview.py
+++ b/g4f/gui/webview.py
@@ -1,24 +1,39 @@
import webview
from functools import partial
-from platformdirs import user_config_dir
+try:
+ from platformdirs import user_config_dir
+ has_platformdirs = True
+except ImportError:
+ has_platformdirs = False
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
+def run_webview(
+ host: str = "0.0.0.0",
+ port: int = 8080,
+ debug: bool = False,
+ storage_path: str = None
+):
+ webview.create_window(
+ f"g4f - {g4f.version.utils.current_version}",
+ f"http://{host}:{port}/",
+ text_select=True
+ )
+ if has_platformdirs and storage_path is None:
+ storage_path = user_config_dir("g4f-webview")
webview.start(
partial(run_gui, host, port),
private_mode=False,
- storage_path=user_config_dir("g4f-webview"),
+ storage_path=storage_path,
debug=debug
)
if __name__ == "__main__":
parser = gui_parser()
args = parser.parse_args()
+ if args.debug:
+ g4f.debug.logging = True
run_webview(args.host, args.port, args.debug) \ No newline at end of file
diff --git a/g4f/gui/webview.spec b/g4f/gui/webview.spec
new file mode 100644
index 00000000..360e264e
--- /dev/null
+++ b/g4f/gui/webview.spec
@@ -0,0 +1,45 @@
+# -*- mode: python ; coding: utf-8 -*-
+
+
+block_cipher = None
+
+
+a = Analysis(
+ ['webview.py'],
+ pathex=[],
+ binaries=[],
+ datas=[],
+ hiddenimports=[],
+ hookspath=[],
+ hooksconfig={},
+ runtime_hooks=[],
+ excludes=[],
+ win_no_prefer_redirects=False,
+ win_private_assemblies=False,
+ cipher=block_cipher,
+ noarchive=False,
+)
+pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
+
+exe = EXE(
+ pyz,
+ a.scripts,
+ a.binaries,
+ Tree('client', prefix='client'),
+ a.zipfiles,
+ a.datas,
+ [],
+ name='webview',
+ debug=False,
+ bootloader_ignore_signals=False,
+ strip=False,
+ upx=True,
+ upx_exclude=[],
+ runtime_tmpdir=None,
+ console=False,
+ disable_windowed_traceback=False,
+ argv_emulation=False,
+ target_arch=None,
+ codesign_identity=None,
+ entitlements_file=None,
+)