Skip to content

Commit

Permalink
use Session functions
Browse files Browse the repository at this point in the history
 * this is the best way to get well-tested preparation and merging
   with pre-existing environment settings, instead of doing the steps
   manually
  • Loading branch information
JunAishima committed Oct 3, 2024
1 parent 06311ea commit 9693d32
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions amostra/client/amutils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
import ujson

import logging
from http.client import HTTPConnection

session = requests.Session()

Expand Down Expand Up @@ -41,7 +42,7 @@ def _get(url, params):
Results of the query
"""
r = session.get(url, ujson.dumps(params))
r = session.get(url, params=ujson.dumps(params))
r.raise_for_status()
return ujson.loads(r.text)

Expand All @@ -57,8 +58,7 @@ def _post(url, data):
Entries to be inserted to database
"""
r = session.post(url,
data=ujson.dumps(data))
r = session.post(url, data=ujson.dumps(data))
r.raise_for_status()
return r.json()

Expand Down Expand Up @@ -86,6 +86,5 @@ def _put(url, query, update):
"""
update_cont = {'query': query, 'update': update}
r = session.put(url,
data=ujson.dumps(update_cont))
r = session.put(url, data=ujson.dumps(update_cont))
r.raise_for_status()

0 comments on commit 9693d32

Please sign in to comment.