| 1 | import requests |
| 2 | |
| 3 | BASE = "https://pasteguru.com" |
| 4 | |
| 5 | r = requests.post(f"{BASE}/api/create", |
| 6 | json={"content": "print('hi')", "title": "demo", "syntax": "python"}, |
| 7 | timeout=10) |
| 8 | r.raise_for_status() |
| 9 | paste = r.json() |
| 10 | print(paste["url"]) # https://pasteguru.com/<id> |
| 11 | |
| 12 | # keep this if you may want to delete the paste later |
| 13 | token = paste["edit_token"] |
| 14 | |
| 15 | raw = requests.get(paste["raw"], timeout=10).text |
| 16 | assert raw == "print('hi')" |
| 17 | |
| 18 | # delete it |
| 19 | requests.post(f"{BASE}/delete/{paste['id']}", data={"edit_token": token}, timeout=10) |
| 20 | |