Files
FastGPT/python/api/test/fetch_test.py
不做了睡大觉 9f889d8806 Create Python API (#457)
* 更新镜像

* 更新镜像信息

* 更新镜像信息

* Create openai_api.py

* Create requirements.txt

* Create README.md

* 添加python接口

* Delete python directory

* Create README.md

* Create Python API

* 文件结构化

* 文件结构化
2023-11-09 11:52:53 +08:00

26 lines
653 B
Python

import requests
# 接口的URL
api_url = "http://127.0.0.1:6010/generate_summary/"
# 请求的数据
data = {
"url": "https://bing.com",
"level": 1
}
# 发送POST请求
response = requests.post(api_url, json=data)
# 检查响应状态
if response.status_code == 200:
# 请求成功,打印结果
summaries = response.json()
for summary in summaries:
print(f"URL: {summary['url']}")
print(f"Title: {summary['title']}")
print(f"Summary: {summary['summary']}\n")
else:
# 请求失败,打印错误信息
print(f"Failed to generate summary with status code {response.status_code}: {response.text}")