feat: json参数

This commit is contained in:
eric
2022-12-14 15:03:09 +08:00
parent 22a766d0ad
commit b5f0ae2658
2 changed files with 6 additions and 2 deletions

Binary file not shown.

View File

@@ -1,5 +1,6 @@
from fastapi import FastAPI from fastapi import FastAPI
import requests import requests
import json
app = FastAPI() app = FastAPI()
@@ -15,6 +16,9 @@ async def root():
async def root(): async def root():
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}
# https://open.feishu.cn/open-apis/bot/v2/hook/5fb1b44c-3446-42ef-9b3a-dd37731567dd # https://open.feishu.cn/open-apis/bot/v2/hook/5fb1b44c-3446-42ef-9b3a-dd37731567dd
r = requests.post('https://httpbin.org/post', try:
data={'msg_type': 'text', "content": {"text": "request example"}}, headers=headers) 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"} return {"message": "触发飞书webhook"}