From fb8de24a9de12a85ecd85d2011d6208400e27147 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 23 Mar 2021 12:14:57 -0700 Subject: [PATCH] Use requests.Session. --- pixelcanvas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pixelcanvas.py b/pixelcanvas.py index 841d10c..a19bc7a 100644 --- a/pixelcanvas.py +++ b/pixelcanvas.py @@ -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