Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds /.well-known/serviceinfo #466

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion horde/apis/apiv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions horde/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions horde/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +30,8 @@
from horde.vars import (
google_verification_string,
horde_contact_email,
horde_logo,
horde_repository,
horde_title,
horde_url,
img_url,
Expand Down Expand Up @@ -391,3 +394,25 @@ def terms():
@HORDE.route("/assets/<filename>")
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
2 changes: 2 additions & 0 deletions horde/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Loading