FSND
#Heroku url: http://messagor.herokuapp.com/
This project is to deploy a Flask application using Heroku and PostgreSQL and enable Role Based Authentication and roles-based access control git (RBAC) with Auth0 (third-party authentication systems).
#Application: Messagor A secure app for communicate easily. Based on administrator role to secure and manage the application.
Python 3.7
Follow instructions to install the latest version of python for your platform in the python docs
You need pip to for next stage
Install dependencies by naviging to the /backend
directory and running:
pip install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt
file.
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
SQLAlchemy is the Python SQL toolkit and ORM we'll use handle the lightweight sqlite database. You'll primarily work in app.py and can reference models.py.
-
Flask-CORS is the extension we'll use to handle cross origin requests from our frontend server.
From within the backend directory first ensure you are working using your created virtual environment.
To run the server, execute:
export FLASK_APP=app.py
flask run
return the token in url.
chat rooms contain name and messages
User or Chatter.
get:rooms get:messages post:messages
All permissions as Administrator.
get:rooms get:messages post:messages patch:messages delete:messages
GET '/rooms'
return list rooms
{
"rooms": [
{
"id": 1,
"name": "main"
}
],
"success": true
}
GET '/rooms/<int:room_id>/messages'
return messages list
{
"messages": [
{
"avatar": "diego",
"content": "how are you?",
"id": 2
},
{
"avatar": "diego",
"content": "test",
"id": 3
},
{
"avatar": "diego",
"content": "test post3",
"id": 4
},
{
"avatar": "diego",
"content": "test post3",
"id": 5
},
{
"avatar": "samantha",
"content": "fine",
"id": 6
},
{
"avatar": "diego",
"content": "good",
"id": 7
}
],
"success": true
}
POST '/rooms/<int:room_id>/messages'
return name avatar and message posted with statut success
{
"avatar": "diego",
"message": "Hi!",
"success": true
}
PATCH '/messages/<int:message_id>'
return message modified and success
{
"message": "change ok",
"success": true
}
DELETE '/messages/<int:message_id>'
return ID and success
{
"deleted": 1,
"messages": [],
"success": true
}
The application retourn this errors:
404: Resource not found
422: unprocessable
401 not authorized
To run the tests go into root folder application and run in your terminal
python test_app.py