0

i am usig flask to run the below posted micro-service. what i am trying to do is to execute the posted url mentioned below so that when it is called it must result in calling the method getDistance2/

in getDistance2 as shown below i am trying to parse the values entered in the url.

the problem is that non of the print statements get executed nor the retuen statement that contains "returned"

please let me know how to input the valued correctly in the url and run the body of getDistance2

url:

http://127.0.0.1:5000/getDistance2/originLng=8.681436&originLat=49.414554&destinationLng=8.681561&destinationLat=49.414747%22

code:

@app.route("/getDistance2/<string:str>", methods=['GET'] )
def getDistance2(originAndDestinationGPSCoords):
    #api_key = request.args.get('api_key')
    # startLat, startLng= request.args.get('start').split(',')
    # end1Lat, endLng = request.args.get('end').split(',')

    a, b, c, d= request.args.get('str').split('&')

    print(a)
    print(b)
    print(c)
    print(d)

    originLng, startLng= request.args.get('originLng').split('&')
    originLat, endLng = request.args.get('originLat').split('&')
    destinationLng, endLng = request.args.get('destinationLng').split('&')
    destinationLat, endLng = request.args.get('destinationLat').split('&')

    print(originLng)
    print(originLat)
    print(destinationLng)
    print(destinationLat)
    print(requear.args.list)

    return "returned"
Amrmsmb
  • 1
  • 27
  • 104
  • 226
  • You need to provide `http://127.0.0.1:5000/getDistance2?...`, note the usage of `?` instead of the `/` to provide a query string as part of the HTTP standard. – metatoaster Mar 14 '21 at 06:03
  • @metatoaster actually it is not working as you suggested – Amrmsmb Mar 14 '21 at 06:09
  • Also, you will need to change the route to `@app.route("/getDistance2", ...)`, as the expected `/` and argument will render the route as it was inaccessible via the intended query sting you want your users to supply. – metatoaster Mar 14 '21 at 06:10
  • Finally, it may be far more useful to search for online tutorials elsewhere (such as [this one](https://pythonise.com/series/learning-flask/flask-query-strings)) and follow it closely to understand the basic principals provided by the pre-built demo, before attempting one yourself. – metatoaster Mar 14 '21 at 06:14

0 Answers0