0x00
玩一下 server 酱
0x01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
import requests
import os from dotenv import load_dotenv import logging load_dotenv()
sckey = os.getenv('SCKEY', None)
if not sckey: raise ValueError()
logger = logging.getLogger() logger.setLevel(logging.DEBUG) handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) logger.addHandler(handler)
def main(text, desp): """ text:消息标题,最长为256,必填 desp:消息内容,最长64Kb,可空,支持MarkDown """ url = F'https://sc.ftqq.com/{sckey}.send'
data = { 'text': text, 'desp': desp, } res = requests.post(url, data=data) logger.info(res.status_code)
if __name__ == "__main__": text = 'server chan 测试' desp = '今天是个好日子' main(text, desp)
|
1 2 3 4
| $ python serverchan.py Starting new HTTPS connection (1): sc.ftqq.com:443 https://sc.ftqq.com:443 "POST /SCU15260Tdeb31f47a7c4564a1cdb288e4ebe1d9559fdf3ea065f8.send HTTP/1.1" 200 None 200
|
通过接入 server 酱,程序报错的时候,给微信发送错误信息,以供排查
还有其他应用场景靠自己想像