init project
This commit is contained in:
25
test.py
Normal file
25
test.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import argparse
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Send a test request to /v1/classify")
|
||||
parser.add_argument("--url", default="http://127.0.0.1:8000/v1/classify")
|
||||
parser.add_argument("--text", default="这家餐厅的服务特别周到,菜也很好吃,我下次还会再来。")
|
||||
parser.add_argument("--timeout", type=int, default=60)
|
||||
args = parser.parse_args()
|
||||
|
||||
response = requests.post(
|
||||
args.url,
|
||||
json={"text": args.text},
|
||||
timeout=args.timeout,
|
||||
)
|
||||
response.raise_for_status()
|
||||
print(json.dumps(response.json(), ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user