Simple Flask boilerplate with register, login, logout endpoints.
Clone the repository
git clone https://github.com/ahmetelgun/flask-boilerplate.git
cd flask-boilerplate
Activate virtualenv and install requirements
pipenv shell
pip install -r requirements.txt
Run tests
python -m unittest
Create Database
python models.py
Start the application
python app.py
flask-boilerplate has 4 enpoints.
{
"firstname": "Anakin",
"lastname": "Skywalker",
"email": "[email protected]",
"password": "padme_amidala"
}
Response takes 3 different response codes.
If user successfully created, returns 200.
If request is invalid, returns 400.
If email is already exists, returns 409.
Response with 200 status code
{
"message": "User successfuly created"
}
{
"email": "[email protected]",
"password": "padme_amidala"
}
Response takes 3 different response codes.
If loggin success, returns 200 with JWT Token in Authorization header.
If request is invalid, returns 400.
If email or password incorrect, returns 401.
Response with 200 status code
{
"message": "Login success"
}
Actually, logout endpoint does nothing. It sends only 200 response without Authorization header whether user logged in or not.
/ endpoint is the test endpoint for authentication. If you send a valid JWT Token in Authorization header, you get a response with 200 status code like this:
{
"message": "welcome, Anakin"
}
If you send a invalid JWT Token in Authorization header, you get a response with 401 status code like this
{
"message": "Login required"
}