Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:param f: filename or file-like object.
:type f: file, str or list
"""
with FilesOpener(f) as files:
response = requests.post(
'https://telegra.ph/upload',
files=files
).json()
if isinstance(response, list):
error = response[0].get('error')
else:
error = response.get('error')
if error:
raise TelegraphException(error)
return [i['src'] for i in response]
def method(self, method, values=None, path=''):
values = values.copy() if values is not None else {}
if 'access_token' not in values and self.access_token:
values['access_token'] = self.access_token
response = self.session.post(
'https://api.telegra.ph/{}/{}'.format(method, path),
values
).json()
if response.get('ok'):
return response['result']
raise TelegraphException(response.get('error'))