Skip to content

Instantly share code, notes, and snippets.

@JohannSuarez
Created January 24, 2022 09:47
Show Gist options
  • Save JohannSuarez/53799429af32c1e0bcfd3daff16f8f26 to your computer and use it in GitHub Desktop.
Save JohannSuarez/53799429af32c1e0bcfd3daff16f8f26 to your computer and use it in GitHub Desktop.
Post Image to FastAPI endpoint
import requests
file_name: str = "hope_sandoval.jpg"
headers = {
'accept': 'application/json',
'Content-Type': 'multipart/form-data',
}
file = {
'image': (file_name, open(file_name, 'rb'), 'image/jpg')
}
response = requests.post('http://127.0.0.1:8000/image', files=file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment