'username': fields.String, 'email': fields.String, 'password': fields.String } # TODO create UserList() with a post that will create a new user class UserList(Resource): def __init__(self): """ Input validation using reqparse """ self.reqparse = reqparse.RequestParser() self.reqparse.add_argument('username', required=True, help='No username provided', location=['form', 'json']) self.reqparse.add_argument('email', required=True, help='No email provided', location=['form', 'json']) self.reqparse.add_argument('password', required=True, help='No password provided', location=['form', 'json']) users_api = Blueprint('resources.users', __name__) api = Api(users_api) api.add_resources(UserList, '/users', endpoint='users')
from flask import Flask from flask_restful import Resource, Api app = Flask(__name__) api = Api(app) class product(Resource): def get(self): return {'products': ['ice cream', 'chocolate', 'Fruit']} api.add_resources(product, '/') if __name__ == '__main__': app.run(host='0.0.0.0', port=80, debug=True)