text: from models import User
  from db import session
  
  from flask_restful import reqparse
  from flask_restful import abort
  from flask_restful import Resource
  from flask_restful import fields
  from flask_restful import marshal_with
  
  user_fields = {
      'id': fields.Integer,
      'username': fields.String,
      'email': fields.String,
      'uri': fields.Url('user', absolute=True),
  }
  parser = reqparse.RequestParser()
  parser.add_argument('username', type=str)
  parser.add_argument('password', type=str)
  parser.add_argument('email', type=str)
  
  
  class UserResource(Resource):
      @marshal_with(user_fields)
      def get(self, id):
          user = session.query(User).filter(User.id == id).first()
          if not user:
              abort(404, message="User {} doesn't exist".format(id))
          return user
  
  
  class UserListResource(Resource):
      @marshal_with(user_fields)
      def get(self):
          users = session.query(User).all()
          return users
  
      @marshal_with(user_fields)
      def post(self):
          parsed_args = parser.parse_args()
          user = User(username=parsed_args['username'],email=parsed_args['email'])
          session.add(user)
          session.commit()
          return user, 201
  