diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-03-15 11:46:06 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-03-15 11:46:06 +0100 |
commit | 8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0 (patch) | |
tree | ea190c7017d8e8982e63a502da0a828d5ba42f94 /g4f/gui | |
parent | Add export / import conversations (diff) | |
download | gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.tar gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.tar.gz gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.tar.bz2 gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.tar.lz gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.tar.xz gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.tar.zst gpt4free-8cc6000ffbf4e12bf6c1d5e5878d376e36857ec0.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/gui/client/js/chat.v1.js | 4 | ||||
-rw-r--r-- | g4f/gui/server/app.py | 8 | ||||
-rw-r--r-- | g4f/gui/server/website.py | 8 |
3 files changed, 16 insertions, 4 deletions
diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js index 24253b2b..c0d0cb6d 100644 --- a/g4f/gui/client/js/chat.v1.js +++ b/g4f/gui/client/js/chat.v1.js @@ -916,16 +916,16 @@ fileInput.addEventListener('change', async (event) => { reader.addEventListener('load', async (event) => { fileInput.dataset.text = event.target.result; if (type == "json") { - const data = JSON.parse(event.target.result); + const data = JSON.parse(fileInput.dataset.text); if ("g4f" in data.options) { Object.keys(data).forEach(key => { if (key != "options" && !localStorage.getItem(key)) { appStorage.setItem(key, JSON.stringify(data[key])); } }); - fileInput.value = ""; delete fileInput.dataset.text; await load_conversations(); + fileInput.value = ""; } } }); diff --git a/g4f/gui/server/app.py b/g4f/gui/server/app.py index 2b55698c..d9e25ca1 100644 --- a/g4f/gui/server/app.py +++ b/g4f/gui/server/app.py @@ -1,3 +1,9 @@ +import sys, os from flask import Flask -app = Flask(__name__, template_folder='./../client/html')
\ No newline at end of file +if getattr(sys, 'frozen', False): + template_folder = os.path.join(sys._MEIPASS, "client/html") +else: + template_folder = "./../client/html" + +app = Flask(__name__, template_folder=template_folder)
\ No newline at end of file diff --git a/g4f/gui/server/website.py b/g4f/gui/server/website.py index 2705664d..9aa98b76 100644 --- a/g4f/gui/server/website.py +++ b/g4f/gui/server/website.py @@ -1,6 +1,12 @@ from flask import render_template, send_file, redirect from time import time from os import urandom +import sys, os + +if getattr(sys, 'frozen', False): + assets_folder = os.path.join(sys._MEIPASS, "client") +else: + assets_folder = "./../client" class Website: def __init__(self, app) -> None: @@ -35,6 +41,6 @@ class Website: def _assets(self, folder: str, file: str): try: - return send_file(f"./../client/{folder}/{file}", as_attachment=False) + return send_file(f"{assets_folder}/{folder}/{file}", as_attachment=False) except: return "File not found", 404
\ No newline at end of file |