📝 Update README with new script example and usage instructions
This commit is contained in:
30
README.md
30
README.md
@@ -45,3 +45,33 @@ pip install cryptography
|
|||||||
```shell
|
```shell
|
||||||
PYTHONPATH=./.venv/lib/python3.10/site-packages/ ./show_my_ip.py
|
PYTHONPATH=./.venv/lib/python3.10/site-packages/ ./show_my_ip.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
`show_myip.py`
|
||||||
|
```python
|
||||||
|
#! /usr/bin/env uv run
|
||||||
|
|
||||||
|
# /// script
|
||||||
|
# requires-python = ">=3.9"
|
||||||
|
# dependencies = [
|
||||||
|
# "requests>=2.32.5",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
import requests;
|
||||||
|
|
||||||
|
IP_ACTION_URL = "https://hatter.ink/ip/ip.jsonp"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
response = requests.get(IP_ACTION_URL, timeout=10)
|
||||||
|
if response.status_code != 200:
|
||||||
|
print("[ERROR]", response.status_code)
|
||||||
|
else:
|
||||||
|
response_json = response.json()
|
||||||
|
print(response_json)
|
||||||
|
print("Your IP is:", response_json['ip'])
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./show_myip.py
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user