diff --git a/main b/main index 352df03..1be83c1 100644 --- a/main +++ b/main @@ -450,6 +450,23 @@ def comment(): "error": "https://http.cat/images/401.jpg" }, 401 +@app.route("/api/post//comments", methods=("GET", "POST")) +def apicomments(post_id): + postthing = get_comments(int(post_id)) + + if not postthing == "error": + comments = [] + for comment in postthing: + commentthing = { + "title": comment["textstr"], + "created": comment["created"], + "creator": { + "id": comment["creator"], + "username": get_user(comment["creator"])["username"] + } + } + comments.append(commentthing) + return comments @app.route("/cdn/", methods=("GET", "POST")) @limiter.limit("8/second", override_defaults=False) diff --git a/templates/apidocs.html b/templates/apidocs.html index 2c25747..40fcacd 100644 --- a/templates/apidocs.html +++ b/templates/apidocs.html @@ -42,7 +42,8 @@ title, being the title of the comment and id, being the ID of the post you want to comment on.

POST /api/login - get authentication key
username, being the username and password, being the password. Returns authentication key.

- GET /api/userinfo - authentication required - Returns user info, username, ID, and account creation date. + GET /api/userinfo - authentication required - Returns user info, username, ID, and account creation date.

+ GET /api/post/1/comments - Returns comments of post