add get comment of post API thing
This commit is contained in:
parent
c72c2bbf72
commit
1fe79a6073
17
main
17
main
|
@ -450,6 +450,23 @@ def comment():
|
|||
"error": "https://http.cat/images/401.jpg"
|
||||
}, 401
|
||||
|
||||
@app.route("/api/post/<post_id>/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/<filename>", methods=("GET", "POST"))
|
||||
@limiter.limit("8/second", override_defaults=False)
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
<code>title</code>, being the title of the comment and <code>id</code>, being the ID of the post you want to comment on.<br><br>
|
||||
POST <code>/api/login</code> - get authentication key<br>
|
||||
<code>username</code>, being the username and <code>password</code>, being the password. Returns authentication key.<br><br>
|
||||
GET <code>/api/userinfo</code> - authentication required - Returns user info, username, ID, and account creation date.
|
||||
GET <code>/api/userinfo</code> - authentication required - Returns user info, username, ID, and account creation date.<br><br>
|
||||
GET <code>/api/post/1/comments</code> - Returns comments of post
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
Reference in New Issue