Create base project or frame for new project Flask with Authorization User
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Install the requirements library
pip install -r requirements.txt
- Migrate the database, this project using MySQL Database.
flask db init && flask db migrate
- Edit first migration file, add following codes then call
seed_data()
intodef upgrade():
from datetime import datetime def seed_data(): app_user = sa.sql.table('app_user', sa.Column('id', sa.Integer()), sa.Column('created_at', sa.TIMESTAMP()), sa.Column('created_by', sa.Integer()), sa.Column('username', sa.String(length=255)), sa.Column('password', sa.String(length=255)), sa.Column('email', sa.String(length=255)), sa.Column('full_name', sa.String(length=255)), sa.Column('enabled', sa.Boolean()), sa.Column('role', sa.String(length=255))) op.bulk_insert(app_user, [ { 'id': 1, 'created_at': datetime.today(), 'created_by': 0, 'username': '<CHANGE_TO_YOUR_USERNAME>', 'password': '<CHANGE_TO_YOUR_HASH_PASSWORD_BASE64>', 'email': '<CHANGE_TO_YOUR_EMAIL>', 'full_name': '<CHANGE_TO_YOUR_NAME>', 'enabled': True, 'role': 'SUPERUSER' } ])
- Update
src/core/config/DatabaseConfig.py
with your database. - Upgrade your migration into MySQL Database
flask db upgrade
- Run the application
python Application.py
for debug orflask run
for deployment.
- Python 3 - The language programming used
- Flask - The web framework used
- Flask-CORS - Flask CORS Filter
- Flask-RestFul - Flask RestFul
- Flask-JWT_Extended - Flask Json Web Token
- Flask Migrate - The database migration
- Virtualenv - The virtual environment used
- SQL Alchemy - The database library
- Flask-SQLAlchemy - Flask and SQL Alchemy connector
- MySQL Connector Python - Connector MySQL for Python
- MySQL - MySQL Database
You can clone or download this project
git clone https://github.com/piinalpin/flask-custom-base-project.git