Skip to content

Commit

Permalink
fix: removing database
Browse files Browse the repository at this point in the history
  • Loading branch information
bacciotti committed May 15, 2024
1 parent 78896ed commit 9fdc238
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
2 changes: 1 addition & 1 deletion application/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def create_app(config_object):
app = Flask(__name__)
api = Api(app)
app.config.from_object(config_object)
init_db(app)
# init_db(app)

api.add_resource(Users, '/users')
api.add_resource(User, '/user', '/user/<string:cpf>')
Expand Down
21 changes: 3 additions & 18 deletions application/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,12 @@

class Users(Resource):
def get(self):
return jsonify(UserModel.objects())
return {"message": "Users / get"}, 200


class User(Resource):
def post(self):
data = _user_parser.parse_args()

try:
response = UserModel(**data).save()
return {
'message': 'User %s created successfully' % response.first_name
}
except NotUniqueError:
return {
'message': 'CPF already exists in the database.'
}
return {"message": "User / post"}, 200

def get(self, cpf):
response = UserModel.objects(cpf=cpf)

if response:
return jsonify(response)

return {"message": "User not found."}, 400
return {"message": "User / get"}, 200

0 comments on commit 9fdc238

Please sign in to comment.