Skip to content

Commit 12b6a50

Browse files
committed
Set user-agent
1 parent abbd111 commit 12b6a50

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

quickchart/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# For Python 3
1111
from urllib.parse import urlencode
1212

13+
USER_AGENT = 'quickchart-python (1.0.0)'
14+
1315
FUNCTION_DELIMITER_RE = re.compile('\"__BEGINFUNCTION__(.*?)__ENDFUNCTION__\"')
1416

1517

@@ -89,7 +91,10 @@ def _post(self, url):
8991
}
9092
if self.key:
9193
postdata['key'] = self.key
92-
resp = requests.post(url, json=postdata)
94+
headers = {
95+
'user-agent': USER_AGENT,
96+
}
97+
resp = requests.post(url, json=postdata, headers=headers)
9398
if resp.status_code != 200:
9499
raise RuntimeError(
95100
'Invalid response code from chart creation endpoint')

0 commit comments

Comments
 (0)