Skip to content

App to register user and user e-mail using json file to storage user data.

Notifications You must be signed in to change notification settings

raissalst/userregister

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Register Application using Flask and JSON

The main goal of this task is to practice the use of Flask framework and to write/load data using JSON file type to storage data.

.

Endpoints:

  • /user -> list all users (GET)
  • /user/:id -> filter user (GET)
  • /user -> register new user (POST)
  • /user/:id -> update user's data (PATCH)
  • /user/:id -> delete user (DELETE)

Request body and expected answers:

***Get list of users***

GET /user

No request body needed.

In case everything works well, the answer shall be like:

STATUS 200

{
  "data": [
    {
      "email": "name@mail.com",
      "id": 1,
      "name": "Name"
    },
    {
      "email": "name@mail.com",
      "id": 2,
      "name": "Name"
    }
  ]
}

***Filter user by id***

GET /user/:id

No request body needed.

In case everything works well, the answer shall be like:

STATUS 200

{
    "email": "name@mail.com",
     "id": 1,
     "name": "Name"
},

Possible errors:

1.- User not found (STATUS 404)

***Register new user***

POST /user

{
  "name": "Name",
  "email": "name@mail.com"
}

In case everything works well, the answer shall be like:

STATUS 201

{
  "email": "name@mail.com",
  "id": 1,
  "name": "Name"
}

Possible errors:

1.- E-mail or name not of string type (STATUS 400)

2.- E-mail already registered (STATUS 409)

3.- Wrong keys error (STATUS 400)

***Update user's data***

It is allowed to change name and/or e-mail data from user.

PATCH /user/:id

{
  "name": "New Name",
  "email": "newmail@mail.com"
}

or only name/email alone.

In case everything works well, the answer shall be like:

STATUS 200

{
  "email": "newmail@mail.com",
  "id": 1,
  "name": "New Name"
}

Possible errors:

1.- E-mail or name not of string type (STATUS 400)

2.- E-mail already registered (STATUS 409)

3.- Wrong keys error (STATUS 400)

4.- User not found (STATUS 404)

***Delete user***

The user data can be deleted.

DELETE /user/:id

No request body needed.

In case everything works well, the answer shall be like:

STATUS 200

{
  "email": "mail@mail.com",
  "id": 1,
  "name": "Name"
}

Possible errors:

1.- User not found (STATUS 404)

About

App to register user and user e-mail using json file to storage user data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published