https://github.com/catalin246/flask-rest
This Flask web app offers a basic API with user authentication. It includes endpoints for managing tasks (todos), secured by JWT tokens for authorized access.
https://github.com/catalin246/flask-rest
api flask jwt python
Last synced: 2 months ago
JSON representation
This Flask web app offers a basic API with user authentication. It includes endpoints for managing tasks (todos), secured by JWT tokens for authorized access.
- Host: GitHub
- URL: https://github.com/catalin246/flask-rest
- Owner: Catalin246
- Created: 2024-02-28T14:14:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-02T19:19:51.000Z (over 2 years ago)
- Last Synced: 2025-01-03T05:28:53.322Z (over 1 year ago)
- Topics: api, flask, jwt, python
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#### FLASK RESTX BOILER-PLATE WITH JWT BUILD ON PYTHON 3.9
### Terminal commands
Note: make sure you have `pip` and `virtualenv` installed.
To run test: flask test
To run application: flask run
Make sure to run the initial migration commands to update the database (from the venv!).
> export FLASK_APP=manage.py
> flask db init
> flask db migrate
> flask db upgrade
### Viewing the app ###
Open the following url on your browser to view swagger documentation
http://127.0.0.1:5000/
### Using Postman / Insomnia ####
Authorization header is in the following format:
Key: Authorization
Value: "token_generated_during_login"
For testing authorization, url for getting all user requires an admin token while url for getting a single
user by public_id requires just a regular authentication.
### Based on : Full description and guide (beware this guide targets an older python version!) ###
https://medium.freecodecamp.org/structuring-a-flask-restplus-web-service-for-production-builds-c2ec676de563
### Errors
`export FLASK_APP=manage.py`
flask shell
from app.main.model.user import User
import datetime
admin = User(email="admin@admin.nl", username="admin", password="admin123",registered_on=datetime.datetime.utcnow(), admin=True)
db.session.add(admin)
db.session.commit()
from app.main.model.user import User
import datetime
admin = User(email="cata@admin.nl", username="cata", password="password",registered_on=datetime.datetime.utcnow(), admin=True)
db.session.add(admin)
db.session.commit()