Skip to content

Instantly share code, notes, and snippets.

@ahvahsky2008
Created March 26, 2021 12:36
Show Gist options
  • Save ahvahsky2008/efa2f93a394c11ee4d9169806e9dfcd6 to your computer and use it in GitHub Desktop.
Save ahvahsky2008/efa2f93a394c11ee4d9169806e9dfcd6 to your computer and use it in GitHub Desktop.
python send file with requests
def send_request (doc):
with open(doc, 'rb') as file:
post_data = {'chat_id': chat_id}
post_file = {'document': file}
r = requests.post(f'https://api.telegram.org/bot{token}/sendDocument', data=post_data, files=post_file)
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment