29 lines
848 B
Python
29 lines
848 B
Python
import asyncio
|
|
import aiohttp
|
|
import json
|
|
|
|
async def test():
|
|
url = "http://localhost:3015/search"
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"X-Workspace": "test1",
|
|
"X-API-Key": "jleu1212"
|
|
}
|
|
data = {
|
|
"query": "what is the minimum safe working distance",
|
|
"mode": "mix",
|
|
"return_raw_data": True,
|
|
"use_keywords": False
|
|
}
|
|
async with aiohttp.ClientSession() as session:
|
|
async with session.post(url, headers=headers, json=data) as resp:
|
|
print(f"Status: {resp.status}")
|
|
if resp.status == 200:
|
|
result = await resp.json()
|
|
print(json.dumps(result, indent=2))
|
|
else:
|
|
text = await resp.text()
|
|
print(f"Error: {text}")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test()) |