urb
urb

Reputation: 964

Route doesn't exist

I have the following code on my service and when requested the return is always 404.

@app.route('/v1/auth/service', methods=['POST'])
def verifyAuthService():
    data = request.get_json()

But in the log file, the service returns 404.

127.0.0.1 - - [TIMEVALUE] "POST /v1/auth/service HTTP/1.1" 404 -

But it works when I use other route. I have checked if the route path or method name are duplicated and didn't find anything.

I request the service method with the following code:

r = requests.post("http://myservice.com:5001/v1/auth/service", json=jPayload)

Upvotes: 3

Views: 893

Answers (2)

urb
urb

Reputation: 964

Maybe was a newbie error, in my init.py file, I haven't imported auth_services.py.

The /v1/auth/service route wasn't interpreted by python so, the route was inaccessible.

Upvotes: 1

Vinod
Vinod

Reputation: 549

Can you try building the URL with below code and match if the route is pointing to exactly same URL which you have called.

from flask import Flask, url_for

app = Flask(__name__)

@app.route('/v1/auth/service', methods=['POST'])
def verifyAuthService():
    data = request.get_json()

with app.test_request_context():
    print url_for('verifyAuthService')

Hope this helps!

Upvotes: 0

Related Questions