Speed up building your scalable application with this boilerplate which includes the latest python support, and a lot more features like Admin panel, SMTP configuration, LRF flow(Login and Registration), mail authentication, separate settings file for root project configuration, travis integration(CI), alembic (database migrations tool), faker(fake data generator), ORM support(SQLAlchemy), Jinja2 (Template Engine) and it is flexible enough for adding and using other libraries.
-If using standard instructions, Python ≥ 3.6 is required.
-A virtual environment is recommended (like virtualenv==20.4.3).
-pip is required for installing software packages.
-It could be easily adapted to run on MySQL or SQLite, but the default installation instructions below assume the use of PostgreSQL.
FlaskBoilerPlate
├── app/
│ ├── api/
│ │ ├── v1/
│ │ │ ├── __init__.py
│ │ │ ├── routes.py
│ │ │ └── views.py
│ │ └── __init__.py
│ ├── auth/
│ │ ├── __init__.py
│ │ ├── forms.py
│ │ ├── models.py
│ │ ├── routes.py
│ │ └── views.py
│ ├── static/
│ │ ├── css/
│ │ ├── img/
│ │ └── js/
│ ├── templates/
│ │ ├── email/
│ │ ├── errors/
│ │ ├── forms/
│ │ ├── layouts/
│ │ └── pages/
│ ├── toolbox/
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ └── email.py
│ ├── __init__.py
│ └── seeding.py
├── env/
├── migrations/
├── config.py
├── requirements.txt
├── run.py
├── WSGI.py
└── README.md
Main project directory where all app are created.This contains following files and folder.
Contains all api versioning and routes files with signup and login apis.
Contains basic authentication features like signup, login, forgot password and reset password views.
Contains the Css, Img and Js files used in your project.
Contains the HTML templates used in your project.
Contain files for flask admin and sending emails.
Main app are register here.
Seeding file for create fake user.
Contains environment variables.
Generates automatically when run database migrations command.
Contains whole projects configurations.
File contains all project dependency.
To run your application.
- User account sign up, login, password reset, all through asynchronous email confirmation.
- Flask-WTForms for Form generation
- Flask-SQLAlchemy with basic User model
- Easy database migrations with Flask-Migrate
- Flask-Admin for administrative task
- PyJWT for JWT token authentication
- Flask-RESTful for Api versioning
- Bootstrap 4 for starter templates
- itsdangerous for generating random tokens for the confirmation emails.
- Faker used for generating fake user for database
- Initialize and activate a virtualenv:
- for windows
virtualenv env \path\to\env\Scripts\activate
- for linux
sudo apt install python3-venv python3 -m venv env source env/bin/activate
- Install the dependencies:
pip install -r requirements.txt # for windows pip3 install -r requirements.txt # for linux
- For database configuration in config.py
POSTGRES = { 'user': 'postgres', 'pw': 'password', 'db': 'my_database', 'host': 'localhost', 'port': '5432', } SQLALCHEMY_DATABASE_URI = 'postgresql:https://%(user)s:\%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRES
- Run command for database migration:
flask db init flask db migrate -m "Initial migration." flask db upgrade
- Run the development server:
- for windows
set FLASK_APP=run.py set FLASK_ENV=development flask run
- for linux
export FLASK_APP=run.py export FLASK_ENV=development flask run
- Navigate to https://localhost:5000
- Generate fake user:
flask seeder --count=n # here n is number of user
- SMTP configuration: