diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-10-29 08:48:04 +0100 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-10-29 08:48:04 +0100 |
commit | d7d1db835ed6670d51823e32c855151813e12fce (patch) | |
tree | 228725193aa025568fba91cd9d8f52f2f73ab86c /g4f/gui/server | |
parent | docs(docs/interference-api.md): update image generation model in usage guide (diff) | |
download | gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.tar gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.tar.gz gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.tar.bz2 gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.tar.lz gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.tar.xz gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.tar.zst gpt4free-d7d1db835ed6670d51823e32c855151813e12fce.zip |
Diffstat (limited to 'g4f/gui/server')
-rw-r--r-- | g4f/gui/server/backend.py | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py index e24d4da2..dc1b1080 100644 --- a/g4f/gui/server/backend.py +++ b/g4f/gui/server/backend.py @@ -1,6 +1,5 @@ import json -import os -from flask import request, Flask, jsonify, send_from_directory +from flask import request, Flask from g4f.image import is_allowed_extension, to_image from .api import Api @@ -55,10 +54,6 @@ class Backend_Api(Api): '/images/<path:name>': { 'function': self.serve_images, 'methods': ['GET'] - }, - '/images': { - 'function': self.get_images, - 'methods': ['GET'] } } @@ -115,19 +110,4 @@ class Backend_Api(Api): Returns: str: A JSON formatted string. """ - return json.dumps(super()._format_json(response_type, content)) + "\n" - - @staticmethod - def get_images(): - images_dir = "./generated_images" - try: - images = [f for f in os.listdir(images_dir) if os.path.isfile(os.path.join(images_dir, f))] - images = [f"/images/{image}" for image in images if image.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.webp'))] - return jsonify(images) - except Exception as e: - return str(e), 500 - - @staticmethod - def serve_images(name): - images_dir = "./generated_images" - return send_from_directory(os.path.abspath(images_dir), name) + return json.dumps(super()._format_json(response_type, content)) + "\n"
\ No newline at end of file |