This project is a simple task manager API built with Flask, allowing users to register, login, and manage their tasks. The frontend is built with plain HTML, CSS, and JavaScript to interact with the backend API.
- User registration and authentication
- Create, read, update, and delete tasks
- Simple frontend for interacting with the API
- Python 3.8 or higher
- Flask
- Flask-SQLAlchemy
- Flask-JWT-Extended
- Werkzeug
- pytest
git clone https://github.com/fiborges/task-manager-api.git
cd task-manager-api
python3 -m venv venv
source venv/bin/activate
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt
python app.py
The application will start running on http://127.0.0.1:5000.
You can test the API using Postman or the provided frontend.
Method: POST URL: http://127.0.0.1:5000/auth/register
{
"username": "testuser",
"password": "testpassword"
}
{
"message": "User created successfully"
}
Method: POST URL: http://127.0.0.1:5000/auth/login
{
"username": "testuser",
"password": "testpassword"
}
{
"token": "<jwt_token>"
}
Method: POST URL: http://127.0.0.1:5000/tasks Headers: Authorization: Bearer <jwt_token>
{
"title": "My first task",
"description": "This is a test task"
}
{
"id": 1,
"title": "My first task",
"description": "This is a test task",
"done": false
}
Method: GET URL: http://127.0.0.1:5000/tasks Headers: Authorization: Bearer <jwt_token>
[
{
"id": 1,
"title": "My first task",
"description": "This is a test task",
"done": false
}
]
Method: PUT URL: http://127.0.0.1:5000/tasks/1 Headers: Authorization: Bearer <jwt_token>
{
"title": "Updated task title",
"description": "Updated task description",
"done": true
}
{
"id": 1,
"title": "Updated task title",
"description": "Updated task description",
"done": true
}
Method: DELETE URL: http://127.0.0.1:5000/tasks/1 Headers: Authorization: Bearer <jwt_token> Response: 204 No Content
Open a web browser and go to http://127.0.0.1:5000. Register a new user. Login with the registered user. Add, update, and delete tasks using the provided interface.
To run the automated tests, use the following command:
pytest
Project Structure
task-manager-api/
├── README.md
├── requirements.txt
├── venv/
├── app.py
├── auth.py
├── models.py
├── static/
│ ├── index.html
│ ├── style.css
│ └── app.js
└── tests/
└── test_app.py
app.py: The main application file. auth.py: Contains authentication routes. models.py: Defines the database models. static/: Contains the frontend files. tests/: Contains the automated tests. venv/: The virtual environment directory. requirements.txt: Lists the dependencies for the project.
Flask: Micro web framework. Flask-SQLAlchemy: Adds SQLAlchemy support to Flask. Flask-JWT-Extended: Adds JWT support to Flask. Werkzeug: Comprehensive WSGI web application library. pytest: Framework for testing Python code.