diff --git a/horde/apis/apiv2.py b/horde/apis/apiv2.py index d566c616..dabb9b69 100644 --- a/horde/apis/apiv2.py +++ b/horde/apis/apiv2.py @@ -6,12 +6,13 @@ from flask_restx import Api from horde.apis.v2 import api as v2 +from horde.consts import HORDE_API_VERSION from horde.vars import horde_contact_email, horde_title blueprint = Blueprint("apiv2", __name__, url_prefix="/api") api = Api( blueprint, - version="2.0", + version=str(HORDE_API_VERSION), title=f"{horde_title}", description=f"The API documentation for the {horde_title}", contact_email=horde_contact_email, diff --git a/horde/consts.py b/horde/consts.py index 25df5ffa..536b8ac7 100644 --- a/horde/consts.py +++ b/horde/consts.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later HORDE_VERSION = "4.44.0" +HORDE_API_VERSION = "2.5" WHITELISTED_SERVICE_IPS = { "212.227.227.178", # Turing Bot diff --git a/horde/routes.py b/horde/routes.py index 380ba027..6172b537 100644 --- a/horde/routes.py +++ b/horde/routes.py @@ -20,6 +20,7 @@ from horde.classes.base import settings from horde.classes.base.news import News from horde.classes.base.user import User +from horde.consts import HORDE_API_VERSION, HORDE_VERSION from horde.countermeasures import CounterMeasures from horde.database import functions as database from horde.flask import HORDE, cache, db @@ -29,6 +30,8 @@ from horde.vars import ( google_verification_string, horde_contact_email, + horde_logo, + horde_repository, horde_title, horde_url, img_url, @@ -391,3 +394,25 @@ def terms(): @HORDE.route("/assets/") def assets(filename): return send_from_directory("../assets", filename) + + +@HORDE.route("/.well-known/serviceinfo") +def serviceinfo(): + return { + "version": "0.1", # This is .well-known version + "software": { + "name": horde_title, + "version": HORDE_VERSION, + "repository": horde_repository, + "homepage": horde_url, + "logo": horde_logo, + }, + "api": { + "aihorde": { + "name": "AI Horde API", + "version": HORDE_API_VERSION, + "base_url": f"{horde_url}/api/v2", + "documentation": f"{horde_url}/api", + }, + }, + }, 200 diff --git a/horde/vars.py b/horde/vars.py index f0a1ae15..f5013f15 100644 --- a/horde/vars.py +++ b/horde/vars.py @@ -42,5 +42,7 @@ horde_title = os.getenv("HORDE_TITLE", "AI Horde") horde_noun = os.getenv("HORDE_noun", "horde") horde_url = os.getenv("HORDE_URL", "https://aihorde.net") +horde_repository = os.getenv("HORDE_REPOSITORY", "https://github.com/Haidra-Org/AI-Horde") +horde_logo = os.getenv("HORDE_LOGO", "https://aihorde.net/assets/img/logo.png") horde_contact_email = os.getenv("HORDE_EMAIL", "aihorde@dbzer0.com") horde_instance_id = str(uuid4())