From 946d4cf1b9214986952512e189360846a2657fe3 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Sun, 9 Jul 2023 21:50:33 +0800 Subject: [PATCH] [doc] add nodeinfo demo --- docs/show.org | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docs/show.org diff --git a/docs/show.org b/docs/show.org new file mode 100644 index 0000000..5851228 --- /dev/null +++ b/docs/show.org @@ -0,0 +1,49 @@ +#+title: Show + +** Nodeinfo +#+begin_src python +from flask import Flask, Response, jsonify +from config import BASE_URL #http://coscup.localhost + +app = Flask(__name__) +@app.route("/.well-known/nodeinfo") +def well_known_nodeinfo() -> Response: + """Return nodeinfo path.""" + return jsonify( + { + "links": [ + { + "rel": "http://nodeinfo.diaspora.software/ns/schema/2.0", + "href": f"{BASE_URL}/nodeinfo/2.0", + } + ] + } + ) + +@app.get("/nodeinfo/2.0") +def nodeinfo() -> Response: + """Return nodeinfo.""" + return jsonify( + { + "version": "2.0", + "software": { + "name": "COSCUP-demo", + "version": "0.0.1", + }, + "protocols": ["activitypub"], + "services": {"inbound": [], "outbound": []}, + "usage": {"users": {"total": 1}}, + "openRegistrations": False, + "metadata": {}, + }, + ) +#+end_src + +#+begin_src restclient +GET http://coscup.localhost/.well-known/nodeinfo +#+end_src + +#+begin_src restclient +GET http://coscup.localhost/nodeinfo/2.0 +#+end_src +