create capsul is working

This commit is contained in:
2021-01-04 15:02:56 -06:00
parent 44e918a974
commit 4833c6250b
6 changed files with 95 additions and 55 deletions

View File

@ -37,11 +37,14 @@ class MyHTTPClient:
return self.client_session
async def post_json(self, url: str, body: str, method="POST", authorization_header=None) -> HTTPResult:
# TODO make a configuration option where this throws an error if the url does not start with https://
response = None
try:
headers = {}
if authorization_header != None:
headers['Authorization'] = authorization_header
if body:
headers['Content-Type'] = "application/json"
response = await self.get_client_session().request(
method=method,
url=url,
@ -85,7 +88,7 @@ class MyHTTPClient:
# i lifted this direct from https://stackoverflow.com/a/58616001
# this is the bridge between Flask's one-thread-per-request world
# and aiohttp's event-loop based world
# and aiohttp's event-loop based world -- it allows us to call run_coroutine from a flask request handler
class EventLoopThread(threading.Thread):
loop = None