Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Flask: Echo GET - using curl and requests

We can test the application externally as well.

For this we first have to make sure the application runs. Then we can use either curl the command line too or the requests library of Python.

curl

curl http://localhost:5000/
curl http://localhost:5000/echo?text=Sanch+Panza

Python requests

pip install requests
import requests

res = requests.get('http://localhost:5000/')
print(res.status_code)
print(res.text)

res = requests.get('http://localhost:5000/echo?text=Hello World!')
print(res.status_code)
print(res.text)