| 123456789101112131415161718192021222324252627282930 |
- # -*- coding: utf-8 -*-
- import httpx
- # Gotify服务器地址
- gotify_url = "https://gotify.erhe.top/message?token=A9KF--mx_12PjSu"
- # 要发送的消息内容
- message = {
- "message": "测试消息",
- "title": "测试标题",
- "priority": 5
- }
- async def send_message():
- async with httpx.AsyncClient() as client:
- try:
- response = await client.post(gotify_url, json=message)
- if response.status_code == 200:
- print("消息发送成功")
- else:
- print(f"消息发送失败,状态码: {response.status_code}")
- except httpx.RequestException as e:
- print(f"请求出现异常: {e}")
- if __name__ == "__main__":
- import asyncio
- asyncio.run(send_message())
|