Flask-Starter
Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development. It has all the ready-to-use bare minimum essentials.
Features
- Flask 2.0, Python (
PEP8
) - Signup, Login with (email, password)
- Forget/reset passwords
- Email verification
- User profile/password updates
- User roles (admin, user, staff)
- User profile status (active, inactive)
- Admin dashboard for management
- Contact us form
- Basic tasks/todo model (easily replace with your use-case)
- Bootstrap template (minimal)
- Utility scripts (initiate dummy database, run test server)
- Test & Production Configs
- Tests [To Do]
async
or not async
Flask 2.0 - asynchronous support in Flask 2.0 is an amazing feature
- however, use it only when it has a clear advantage over the equivalent synchronous code
- write asynchronous code, if your application's routes, etc. are making heavy I/O-bound operations, like:
- sending emails, making API calls to external servers, working with the file system, etc
- otherwise, if your application is doing CPU-bound operations or long-running tasks, like:
- processing images or large files, creating backups or running AI/ML models, etc
- it is advised to use tools like "Celery" or "Huey", etc.
async
demo in our application
Check emails/__init__.py
to see how emails being sent in async
mode
Primary Goals
- To help you save lots of hours as a developer, even if for a hobby project or commercial project :-)
- To provide basic features of standard web apps, while staying as unopinionated as possible
- To make back-end development quick to start, with robust foundations
- To help you quickly learn how to build a Flask based web application
- To help you quick start coding your web app's main logic and features
Table of Contents
Getting Started
clone the project
$ git clone https://github.com/ksh7/flask-starter.git
$ cd flask-starter
create virtual environment using python3 and activate it (keep it outside our project directory)
$ python3 -m venv /path/to/your/virtual/environment
$ source <path/to/venv>/bin/activate
install dependencies in virtualenv
$ pip install -r requirements.txt
setup flask
command for our app
$ export FLASK_APP=manage.py
$ export FLASK_ENV=development
create instance folder in /tmp
directory (sqlite database, temp files stay here)
$ mkdir /tmp/flaskstarter-instance
initialize database and get two default users (admin & demo), check manage.py
for details
$ flask initdb
- start test server at
localhost:5000
$ flask run
Screenshots
Project Structure
flask-starter/
βββ flaskstarter
βΒ Β βββ app.py
βΒ Β βββ config.py
βΒ Β βββ decorators.py
βΒ Β βββ emails
βΒ Β βΒ Β βββ __init__.py
βΒ Β βββ extensions.py
βΒ Β βββ frontend
βΒ Β βΒ Β βββ forms.py
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ models.py
βΒ Β βΒ Β βββ views.py
βΒ Β βββ __init__.py
βΒ Β βββ settings
βΒ Β βΒ Β βββ forms.py
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ views.py
βΒ Β βββ static
βΒ Β βΒ Β βββ bootstrap.bundle.min.js
βΒ Β βΒ Β βββ bootstrap.min.css
βΒ Β βΒ Β βββ jquery.slim.min.js
βΒ Β βββ tasks
βΒ Β βΒ Β βββ forms.py
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ models.py
βΒ Β βΒ Β βββ views.py
βΒ Β βββ templates
βΒ Β βΒ Β βββ admin
βΒ Β βΒ Β βΒ Β βββ index.html
βΒ Β βΒ Β βββ dashboard
βΒ Β βΒ Β βΒ Β βββ dashboard.html
βΒ Β βΒ Β βββ frontend
βΒ Β βΒ Β βΒ Β βββ change_password.html
βΒ Β βΒ Β βΒ Β βββ contact_us.html
βΒ Β βΒ Β βΒ Β βββ landing.html
βΒ Β βΒ Β βΒ Β βββ login.html
βΒ Β βΒ Β βΒ Β βββ reset_password.html
βΒ Β βΒ Β βΒ Β βββ signup.html
βΒ Β βΒ Β βββ layouts
βΒ Β βΒ Β βΒ Β βββ base.html
βΒ Β βΒ Β βΒ Β βββ header.html
βΒ Β βΒ Β βββ macros
βΒ Β βΒ Β βΒ Β βββ _confirm_account.html
βΒ Β βΒ Β βΒ Β βββ _flash_msg.html
βΒ Β βΒ Β βΒ Β βββ _form.html
βΒ Β βΒ Β βΒ Β βββ _reset_password.html
βΒ Β βΒ Β βββ settings
βΒ Β βΒ Β βΒ Β βββ password.html
βΒ Β βΒ Β βΒ Β βββ profile.html
βΒ Β βΒ Β βββ tasks
βΒ Β βΒ Β βββ add_task.html
βΒ Β βΒ Β βββ edit_task.html
βΒ Β βΒ Β βββ my_tasks.html
βΒ Β βΒ Β βββ view_task.html
βΒ Β βββ user
βΒ Β βΒ Β βββ constants.py
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ models.py
βΒ Β βββ utils.py
βββ manage.py
βββ README.md
βββ requirements.txt
βββ screenshots
βββ tests
βββ __init__.py
βββ test_flaskstarter.py
Modules
This application uses the following modules
- Flask
- Flask-SQLAlchemy
- Flask-WTF
- Flask-Mail
- Flask-Caching
- Flask-Login
- Flask-Admin
- pytest
- Bootstrap (bare minimum so that you can replace it with any frontend library)
- Jinja2
Testing
Note: This web application has been tested thoroughly during multiple large projects, however tests for this bare minimum version would be added in tests
folder very soon to help you get started.
π€
Need Help? If you need further help, reach out to me via Twitter DM.