Skip to content

Latest commit

 

History

History
299 lines (221 loc) · 3.77 KB

ROUTES.md

File metadata and controls

299 lines (221 loc) · 3.77 KB

Routes wannadbBackend

The Flask app is running by default on port 8000. Here we assume that the app is running on localhost.



HelloWorld

GET

http://localhost:8000/

Register

POST

Register a new user.

http://localhost:8000/register

Body

{
    "username": "username",
    "password": "password"
}

Response

  • 422 : User register failed:
    {
        "message": "User register failed"
    }
  • 201: User register success:
    {
        "message": "User registered successfully",
        "token": "eyJhbGciOiJIUI1NiIsIn5cCI6IkpXVCJ9.ey1c2VyIjocGhpbEiLCJpZCIM30.v_lKLd0X-PABkRFXHZa..."
    }

Login

POST

Login as user

http://localhost:8000/login

Body

{
    "username": "username",
    "password": "password"
}

Response

  • 401: User login failed:
    {
        "message": "Wrong Password"
    }
  • 200: User login success:
    {
        "message": "Log in successfully",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1..."
    }

Organisation

POST

creatOrganisation

http://localhost:8000/creatOrganisation

Body

{
    "authorization": "---",
    "organisationName": "---"
}

Response

  • 409: duplication Conflict:
    {
        "error": "name already exists."
    }
  • 200: success:
    {
        "organisation_id": "---"
    }

GET

getOrganisationMembers

http://localhost:8000/getOrganisationMembers/<id>

Header

{
    "authorization": "---"
}

Response

  • 404: Organisation not found:
    {
        "error": "Organisation not found."
    }
  • 401: User not authorized:
    {
        "error": "User not authorized."
    }
  • 200: success:
    {
        "members": ["username1", "username2", "username3"]
    }

POST

leaveOrganisation

Leave a organisation and delete the organisation if the user is the last member.

http://localhost:8000/leaveOrganisation

Body

{
    "authorization": "---",
    "organisationId": "---"
}

Response

  • 500: error:
    {
        "status": false,
        "msg": "error message"
    }
  • 200: success:
    {
        "status": true
    }

POST

addUserToOrganisation

http://localhost:8000/addUserToOrganisation

Body

{
    "authorization": "---",
    "organisationName": "---",
    "newUser": "---"
}

Response

  • 409: duplication Conflict: (temp)
    {
        "error": "error message"
    }
  • 200: success:
    {
        "organisation_id": "---"
    }

Upload Files

POST

Upload files.

http://localhost:8000/data/upload

Body

  • file (form-data): Files to upload
  • authorization (form-data): User authorization token
  • organisationId (form-data): Organization ID

Response

  • 400: Upload failed:
    Returns a list of document file types.
    
  • 207: Upload partial success:
    Returns a list of document file types and documentIds.
    
  • 201: Upload success:
    Returns a list of documentIds.
    

Get Dokument

POST

get file.

http://localhost:8000/dev/getDocument/<_id>

Body

  • None

Response

  • String of File Content

create-tables

POST

Create tables (Development).

http://localhost:8000/create-tables