Last active
February 1, 2025 15:02
-
-
Save up1/a441d0beed6bea37a6b5e3fc3e0c1e67 to your computer and use it in GitHub Desktop.
Posting :: API tesing in terminal
This file contains 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
# quick install on MacOS/Linux | |
curl -LsSf https://astral.sh/uv/install.sh | sh | |
# install Posting (will also quickly install Python 3.12 if needed) | |
uv tool install --python 3.12 posting | |
# Use to run script | |
uv tool install posting --with httpx | |
# Start | |
$posting |
This file contains 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
name: demo01 | |
url: https://jsonplaceholder.typicode.com/users/1 | |
scripts: | |
on_response: testing/test_response.py |
This file contains 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
from posting import Posting | |
import httpx | |
def on_response(response: httpx.Response, posting: Posting) -> None: | |
print(response.status_code) | |
# check status code 200 | |
if response.status_code == 200: | |
posting.notify("Success") | |
else: | |
posting.notify("Failed", severity="error") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment