Simple GET request

import requests

    request_url = f"http://192.168.1.123/some_file"
    response = requests.get(request_url)
    if response.status_code == 200:
        print("Success: \n" + response.text)
    else:
        print("Error: " + response.status_code)

Get Byte array of response (e.g. raw byte array of a returned file)

import requests
import io

    request_url = f"http://192.168.1.123/some_file"
    response = requests.get(request_url)
    if response.status_code == 200:
        image1 = Image.open(io.BytesIO(response.content))

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *