0

I have an API with 12 endpoints which was working fine, then the endpoints started failing and now all return 404 status code. Here are some of my files My run.py

import os

from app import create_app

config = os.getenv('APP_SETTINGS')
app = create_app(config)

if __name__ == "__main__":
    app.run(debug=True)

I register my endpoints in app.py like so

 from flask import Flask
 from .api.v2.views.userview import auth


 def create_app(config):
 '''Creates all Flask configurations and returns app.
    Expects config name'''
     app = Flask(__name__, instance_relative_config=True)
     app.config['JSON_SORT_KEYS'] = False
     app.config.from_object(app_config[config])
     app.config.from_pyfile('config.py', silent=True)

     app.url_map.strict_slashes = False
     app.register_blueprint(auth)
     return app

And finally my endpoint user.py

     from flask import request, jsonify
     from flask import Blueprint

     from ..models.usermodel import UserModel

     usr_obj = UserModel()
     auth = Blueprint('auth', __name__, '/api/v2')


     @auth.route('/auth/signup', methods=['POST'])
     def user_signup():
         fullname = request.json['fullname']
         username = request.json['username']
         email = request.json['email']
         password = request.json['password']

         data = usr_obj.inituser(fullname, username, email, password)
         return jsonify(data), 201

When I try to run this endpoint or any other in Version 1 (/api/v1) I get a Not Found error. I have also tried THIS SOLUTION with no success.

enter image description here

John Nyingi
  • 951
  • 1
  • 16
  • 36

1 Answers1

1

I made a silly mistake the Blueprint declaration ought to be

 auth = Blueprint('auth', __name__, url_prefix='/api/v2')
John Nyingi
  • 951
  • 1
  • 16
  • 36