2025-09-07 08:47:04 +08:00
2025-08-27 23:31:34 +08:00
2025-09-04 23:38:22 +08:00
2025-09-03 22:39:43 +08:00
2025-09-06 23:27:58 +08:00
2025-09-09 21:53:38 +08:00
2025-09-03 22:57:15 +08:00
2025-09-03 23:37:32 +08:00
2025-09-03 23:37:32 +08:00
2025-10-01 21:06:49 +10:00
2025-08-28 22:58:31 +08:00
2025-09-06 23:21:40 +08:00
2025-09-04 00:06:05 +08:00
2025-09-03 00:37:25 +08:00
2025-09-05 00:52:21 +08:00
2025-09-03 23:15:38 +08:00
2025-09-09 21:53:38 +08:00
2025-09-04 23:38:22 +08:00
2025-09-05 00:54:52 +08:00
2025-09-03 23:53:30 +08:00
2025-10-01 21:01:26 +10:00
2025-09-03 23:39:26 +08:00
2025-09-03 23:15:38 +08:00

python-tests

Python tool: https://github.com/astral-sh/uv

uvx pycowsay 'hello world!'
$ echo 'import requests; print(requests.get("https://astral.sh"))' > example.py

$ uv add --script example.py requests
Updated `example.py`
$ uv run example.py
Reading inline script metadata from: example.py
Installed 5 packages in 12ms
<Response [200]>
uv run --python 3.12 https://git.hatter.ink/hatter/python-tests/raw/branch/main/leap_year.py
uv run 'https://script.hatter.ink/@0/show_myip.py'

https://developer.aliyun.com/mirror/pypi/

~/.pip/pip.conf

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com
pip install requests
pip install cryptography

PYTHONPATH=./.venv/lib/python3.10/site-packages/ ./show_my_ip.py 

show_myip.py

#! /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'])
./show_myip.py 
Description
No description provided
Readme 114 KiB
Languages
Python 100%