You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
571 B

import requests
# 目标 URL
url = 'http://127.0.0.1:8000/polls/roll_call/'
# 发送 POST 请求,模拟教师点击“开始点名”按钮
data = {
'start_roll_call': 'true' # 发送一个模拟参数以触发点名功能
}
response = requests.post(url, json=data) # 使用 json 参数
# 检查响应状态和内容
if response.status_code == 200:
try:
print("点名成功:", response.json())
except ValueError:
print("响应不是有效的 JSON:", response.text)
else:
print("点名失败:", response.status_code, response.text)