-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.py
40 lines (32 loc) · 985 Bytes
/
utils.py
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
import json
"""
utils for aiohttp.
"""
async def get_url(session, path, headers) -> str:
"""
aiohttp: for use with GET requests
"""
async with session.get(path, headers=headers) as resp:
res = await resp.read()
return res
async def post_jurl(session, path, headers, json) -> json:
"""
aiohttp: for use with JSON in POST requests
"""
async with session.post(url=path, headers=headers, json=json) as resp:
res = await resp.json()
return res
async def post_url(session, path, headers, body) -> json:
"""
aiohttp: for use with BODY in POST requests
"""
async with session.post(url=path, headers=headers, data=body) as resp:
res = await resp.json()
return res
async def delete_url(session, path, headers) -> str:
"""
aiohttp: for use with DELETE requests
"""
async with session.delete(path, headers=headers) as resp:
res = await resp.text()
return res