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.
25 lines
574 B
Python
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()
|