I use a python library(aiohttp) to get the response form post request. Can I get sequential result? How to...?
import aiohttp
import asyncio
import base64
import json
from tqdm import tqdm
import time
f = open('C:\\Users\\fangchao\\Pictures\\face1.jpg', 'rb').read()
image_64_encode = base64.b64encode(f).decode("utf-8")
files = {"target1": {"photoFormat": "image/jpeg", "photoData": image_64_encode, "faceLocator": None}, "target2": {"photoFormat": "image/jpeg", "photoData": image_64_encode, "faceLocator": None}, "threshold": 0}
url = "http://10.122.100.64:8080/v4/query/verify"
async def fetch(session, url):
async with session.post(url, data=json.dumps(files)) as response:
return await response.text()
async def main(url):
async with aiohttp.ClientSession() as session:
html = await fetch(session, url)
text = json.loads(html)
print(text["score"])
a = time.time()
loop = asyncio.get_event_loop()
tasks = [main(url) for i in range(1000)]
loop.run_until_complete(asyncio.wait(tasks))
print(time.time() - a)
Only can i get a score form response, so I want to know what two images are if I use many post to get response. So I need a sequential result