Use requests.Session.

This commit is contained in:
voussoir 2021-03-23 12:14:57 -07:00
parent b6f801568f
commit fb8de24a9d
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -83,6 +83,8 @@ sql = sqlite3.connect('pixelcanvas.db')
cur = sql.cursor()
cur.executescript(DB_INIT)
session = requests.Session()
# HELPER FUNCTIONS
################################################################################
def now():
@ -153,7 +155,7 @@ def url_for_bigchunk(bigchunk_x, bigchunk_y):
return f'http://api.pixelcanvas.io/api/bigchunk/{bigchunk_x}.{bigchunk_y}.bmp'
def request(url):
response = requests.get(url)
response = session.get(url)
response.raise_for_status()
return response