Last active
March 30, 2021 07:53
-
-
Save BlaneyXYZ/98469ddd523c43cd4ded69d679104e4e to your computer and use it in GitHub Desktop.
PUT all files in a folder to a REST endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import requests | |
from requests.auth import HTTPBasicAuth | |
directory = os.fsencode(os.getcwd()) | |
for file in os.listdir(directory): | |
filename = os.fsdecode(file) | |
response = requests.post('http://localhost', files={'file': open(filename, 'rb')}, auth=HTTPBasicAuth('user', 'pass')) | |
print(response.content) | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment