Created
March 15, 2024 05:27
-
-
Save Rayquaza01/6f4fe81cc127227e27d22b63f000ae8c to your computer and use it in GitHub Desktop.
Picotron Mastodon Proof of Concept
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from textwrap import wrap | |
| import requests | |
| from markdownify import markdownify | |
| from flask import Flask, request | |
| app = Flask(__name__) | |
| @app.route("/statuses") | |
| def root(): | |
| url = "https://" + request.args.get("server") + "/api/v1/statuses/" + request.args.get("id") | |
| res = requests.get(url) | |
| js = res.json() | |
| username = js["account"]["display_name"] | |
| acct = js["account"]["acct"] | |
| created_at = js["created_at"] | |
| content = "\n".join(wrap(markdownify(js["content"]), width=96)) | |
| media = "" | |
| for attachment in js["media_attachments"]: | |
| if attachment["description"] is None: | |
| attachment["description"] = "No alt text provided :(" | |
| media += "\n".join(wrap(attachment["description"], width=96)) + "\n\n" | |
| response = username + " @" + acct + "\n" + created_at + "\n\n" + content + "\n\nAttachments\n" + media | |
| return response | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=5000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _init() | |
| server = "" | |
| id = "" | |
| api = fetch("http://localhost:5000/statuses?server=" .. server .. "&id=" .. id) | |
| end | |
| function _draw() | |
| cls() | |
| print(api) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment