forked from 3wordchant/capsul-flask
create capsul is working
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user