Files
devplacepy/examples/devrant/post_rant.py
T
retoor c151325916 feat: add plug-and-play devRant API client examples with Python and JavaScript
Add complete set of example scripts for the devRant REST protocol under
examples/devrant/, including reusable client libraries, a rant poster,
a live feed watcher with keyword-based auto-upvote, and an end-to-end
smoke test that exercises every endpoint. Both Python (stdlib-only) and
JavaScript (Node 18+ global fetch) implementations are provided.
2026-06-14 07:48:37 +00:00

25 lines
574 B
Python

# retoor <retoor@molodetz.nl>
import sys
from client import from_env
def main() -> None:
if len(sys.argv) < 2:
print("usage: DEVRANT_USERNAME=.. DEVRANT_PASSWORD=.. python post_rant.py <text> [tags]")
raise SystemExit(1)
text = sys.argv[1]
tags = sys.argv[2] if len(sys.argv) > 2 else ""
api = from_env()
api.login()
result = api.post_rant(text, tags)
if result.get("success"):
print(f"posted rant {result['rant_id']}")
else:
print(f"failed: {result.get('error')}")
if __name__ == "__main__":
main()