Search code examples
pythonpython-3.xflaskserverrequest

How to make a GET request to Flask server


So, I've made a Flask server using Python on REPL and I'm trying to tell people how to use it. To do so, I'm making an example using Python. So far I have:


import requests
baseURL = "https://myurl.repl.co"
x = requests.get(baseURL)
print(x)
But what I get is: <Response [200]>
When I try to get an item from there, I get: Traceback (most recent call last): File "main.py", line 6, in <module> print(x[0]) TypeError: 'Response' object is not subscriptable

Does anyone know how to properly make a GET request to the server? Thanks!


Solution

  • import requests
    baseURL = "https://myurl.repl.co"
    x = requests.get(baseURL)
    
    print(x.content)