Skip to content

Instantly share code, notes, and snippets.

@gajanan0707
Last active October 5, 2022 12:12
Show Gist options
  • Save gajanan0707/20ea0636ee725730aac6f67ddbce4cb3 to your computer and use it in GitHub Desktop.
Save gajanan0707/20ea0636ee725730aac6f67ddbce4cb3 to your computer and use it in GitHub Desktop.
FLASK_DEMO_REST/users/views.py
from flask import Response
from flask_restful import Resource
from flask import request, make_response
from users.service import create_user, reset_password_email_send, login_user, reset_password
class SignUpApi(Resource):
@staticmethod
def post() -> Response:
"""
POST response method for creating user.
:return: JSON object
"""
input_data = request.get_json()
response, status = create_user(request, input_data)
return make_response(response, status)
class LoginApi(Resource):
@staticmethod
def post() -> Response:
"""
POST response method for login user.
:return: JSON object
"""
input_data = request.get_json()
response, status = login_user(request, input_data)
return make_response(response, status)
class ForgotPassword(Resource):
@staticmethod
def post() -> Response:
"""
POST response method for forgot password email send user.
:return: JSON object
"""
input_data = request.get_json()
response, status = reset_password_email_send(request, input_data)
return make_response(response, status)
class ResetPassword(Resource):
@staticmethod
def post(token) -> Response:
"""
POST response method for save new password.
:return: JSON object
"""
input_data = request.get_json()
response, status = reset_password(request, input_data, token)
return make_response(response, status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment