I need to use my localhost address as the URL. In my endpoint, I have a few different airport codes to get the temperature from a JSON string.
I can type in my browser localhost:5555/temp/lax
and the output on that address is just the temperature in Fahrenheit.
I am trying to write a command-line client that will do something like this:
python temp.py sfo
And I will get the output of the temperature at SFO airport.
In the endpoint program, I have my route as:
@app.route('/temp/<airportcode>')
In my mediocre command line client I can get the temperature to print out when I specify exactly what airport I want to see the temp at.
This will work: http://127.0.0.1:5555/temp/lax
But if I try to use this:
t = requests.post("http://127.0.0.1:5555/temp/<airportcode>")
I get a swarm of bad requests.
I also tried requests.get
but got the same result.