Hello I'm trying using Flask Restplus, I changed the Base URL from '/' to '/api'. When the base URL is '/' it give me the JSON data. After I changed the base URL to '/api' it didn't give me the data, only give me the Flask-restplus API page.
This is my code
from flask import Blueprint
from flask_restplus import Api
# change base url '/' to '/api'
blueprint = Blueprint('api', __name__, url_prefix='/api/')
api = Api(blueprint,
title="Enrollment API",
version='v0.1',
description='Enrollment API for CRUD operation'
)
app.register_blueprint(blueprint)
@api.route('/api','/api/')
class GetAndPost(Resource):
''' Get All '''
def get(self):
return jsonify(User.objects.all())
''' POST '''
def post(self):
data = api.payload
user_id = data['user_id']
email = data['email']
first_name = data['first_name']
last_name = data['last_name']
password = data['password']
user = User(user_id=user_id, email=email, first_name=first_name, last_name=last_name)
user.set_password(password)
user.save()
return jsonify(User.objects(user_id=user_id))
I would like to get all json data when accessing '/api'. How to fix this issue?