Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

write me a py script that sends a get to…

  1. User

    PROMPT: user: write me a py script that sends a get to https://yuntian-deng-chatgpt4.hf.space/queue/data?session_hash=26vb4jk6379

  2. Assistant

    Certainly! Below is a simple Python script that uses the requests library to send a GET request to the specified URL. Make sure you have the requests library installed. You can install it using pip if you haven't already:

    pip install requests
    

    Here's the script:

    import requests
    
    def send_get_request(url):
        try:
            response = requests.get(url)
            
            # Check if the request was successful (status code 200)
            if response.status_code == 200:
                print("Success:")
                print(response.json())  # Assuming the response is in JSON format
            else:
                print(f"Request failed with status code: {response.status_code}")
                print(response.text)  # Print the response text for debugging
    
        except requests.exceptions.RequestException as e:
            print(f"An error occurred: {e}")
    
    if __name__ == "__main__":
        url = "https://yuntian-deng-chatgpt4.hf.space/queue/data?session_hash=26vb4jk6379"
        send_get_request(url)
    

    How to Use:

    1. Save the script in a file named get_request.py.

    2. Run the script using Python:

      python get_request.py
      

    This script will send a GET request to the specified URL and print the response. If the response is successful, it will print the JSON data; otherwise, it will print the error details.