forked from Sen-illion/DN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api2.py
More file actions
40 lines (36 loc) · 1.23 KB
/
test_api2.py
File metadata and controls
40 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
import requests
import json
import sys
import os
data = {
"gameTheme": "新世纪福音战士",
"protagonistAttr": {
"looks": "普通",
"intelligence": "普通",
"stamina": "普通",
"charisma": "普通"
},
"difficulty": "困难",
"toneKey": "aesthetic",
"imageStyle": "anime"
}
print("Sending request...", flush=True)
resp = requests.post("http://127.0.0.1:5001/generate-worldview", json=data, timeout=300)
print(f"Status: {resp.status_code}", flush=True)
result = resp.json()
print(f"Response status: {result.get('status', 'N/A')}", flush=True)
print(f"Response keys: {list(result.keys())}", flush=True)
# Print full response structure
for k, v in result.items():
if isinstance(v, dict):
print(f" {k}: dict with keys {list(v.keys())[:10]}", flush=True)
elif isinstance(v, str) and len(v) > 200:
print(f" {k}: {v[:200]}...", flush=True)
else:
print(f" {k}: {v}", flush=True)
# Save to temp
save_path = os.path.join(os.environ.get("TEMP", "C:\\Temp"), "game_state.json")
with open(save_path, "w", encoding="utf-8") as f:
json.dump(result, f, ensure_ascii=False, indent=2, default=str)
print(f"Saved to: {save_path}", flush=True)