Files
gitlab-instance-0a899031_fa…/app/main.py
2022-12-14 15:03:09 +08:00

25 lines
660 B
Python

from fastapi import FastAPI
import requests
import json
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
# 飞书通知
@app.get("/feishu")
async def root():
headers = {'Content-Type': 'application/json'}
# https://open.feishu.cn/open-apis/bot/v2/hook/5fb1b44c-3446-42ef-9b3a-dd37731567dd
try:
r = requests.post('https://open.feishu.cn/open-apis/bot/v2/hook/5fb1b44c-3446-42ef-9b3a-dd37731567dd',
data=json.dumps({'msg_type': 'text', "content": {"text": "request example"}}), headers=headers)
except(e):
print('e')
return {"message": "触发飞书webhook"}