2

I just created an API using Flask on Heroku (POST request). I understand how to send a request and print out the results, but I would like to know what the full URL is that is being sent so I can use the API outside of Python. I'd imagine it should be something like apiurl.com/id=3&url=url.com&.... As a test example, I've created https://test-my-flask0.herokuapp.com/ which just takes a single number and adds 2 to it. For example:

import json 
import requests

url = "https://test-my-flask0.herokuapp.com/"
data = 2
data = json.dumps(data)
send_request = requests.post(url, data)

print(send_request)
>> <Response [200]>

print(send_request.json())
>> {'results': {'results': 4.0}}

What's a flexible way I could get the URL that's being sent to create such a request? My actual API is a bit more complex with strings and arrays and such as inputs, so I'm needing a flexible way to determine the associated URL. Sorry if I'm using unclear terminology- this is my first API. Thanks.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
acciolurker
  • 429
  • 4
  • 15

0 Answers0