AI butler Jarvis

This commit is contained in:
fiatrete
2023-06-05 13:21:34 +08:00
parent 41578de486
commit c01b07e61e
68 changed files with 4451 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import asyncio
import json
import time
from typing import List, Dict
import aiohttp
async def do_post(url, body, params=None) -> Dict | List:
if not isinstance(body, str):
body = json.dumps(body)
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
async with aiohttp.ClientSession() as session:
async with session.post(url, headers=headers, data=body, params=params) as response:
return await response.json()
async def do_get(url, params=None) -> Dict | List:
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers, params=params) as response:
return await response.json()