Flask-AppBuilder
Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/
Top Related Projects
The Python micro framework for building web applications.
FastAPI framework, high performance, easy to learn, fast to code, ready for production
The Web framework for perfectionists with deadlines.
Web APIs for Django. 🎸
Ready-to-use and customizable users management for FastAPI
Quick Overview
Flask-AppBuilder is a web application framework built on top of the Flask web framework. It provides a set of tools and utilities to help developers quickly build web applications with common features such as authentication, role-based access control, and database integration.
Pros
- Rapid Development: Flask-AppBuilder abstracts away many common web application tasks, allowing developers to focus on building the core functionality of their application.
- Extensible: The framework is designed to be highly extensible, with a plugin system that allows developers to add new features and functionality as needed.
- Security: The framework includes built-in support for authentication and role-based access control, helping to ensure the security of web applications.
- Database Integration: Flask-AppBuilder integrates with popular database libraries such as SQLAlchemy, making it easy to work with relational databases.
Cons
- Steep Learning Curve: The framework has a relatively steep learning curve, especially for developers who are new to Flask or web development in general.
- Limited Documentation: The documentation for Flask-AppBuilder can be sparse in some areas, which can make it difficult for new users to get started.
- Performance: The framework's abstraction and built-in features can add some overhead, which may impact the performance of larger or more complex web applications.
- Limited Customization: While the framework is extensible, some developers may find that it limits their ability to customize the application to their specific needs.
Code Examples
Here are a few examples of how to use Flask-AppBuilder:
- Creating a Model:
from flask_appbuilder import Model
from sqlalchemy import Column, Integer, String
class MyModel(Model):
id = Column(Integer, primary_key=True)
name = Column(String(50), nullable=False)
description = Column(String(150), nullable=True)
- Creating a View:
from flask_appbuilder.views import ModelView
class MyModelView(ModelView):
datamodel = SQLAInterface(MyModel)
list_columns = ["name", "description"]
add_columns = ["name", "description"]
edit_columns = ["name", "description"]
- Registering a View:
from flask_appbuilder import CRUD
from .views import MyModelView
appbuilder.add_view(
MyModelView,
"My Model",
icon="fa-folder-open-o",
category="My Category",
)
- Securing a View:
from flask_appbuilder.security.decorators import has_access
class MyModelView(ModelView):
@has_access
def my_view(self):
# View logic goes here
pass
Getting Started
To get started with Flask-AppBuilder, follow these steps:
- Install the library using pip:
pip install flask-appbuilder
- Create a new Flask application and initialize the Flask-AppBuilder extension:
from flask import Flask
from flask_appbuilder import AppBuilder, SQLA
app = Flask(__name__)
app.config.from_object("config")
db = SQLA(app)
appbuilder = AppBuilder(app, db.session)
- Define your data models and views:
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_appbuilder.views import ModelView
class MyModel(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
description = db.Column(db.String(150), nullable=True)
class MyModelView(ModelView):
datamodel = SQLAInterface(MyModel)
list_columns = ["name", "description"]
add_columns = ["name", "description"]
edit_columns = ["name", "description"]
appbuilder.add_view(MyModelView, "My Model", icon="fa-folder-open-o", category="My Category")
- Run the application:
flask run
That's it! You now have a basic Flask-AppBuilder application up and running.
Competitor Comparisons
The Python micro framework for building web applications.
Pros of Flask
- Lightweight and minimalist, offering more flexibility and control
- Easier to learn and understand for beginners
- Extensive documentation and large community support
Cons of Flask
- Requires more manual setup and configuration for complex applications
- Lacks built-in admin interface and user management features
- May require additional extensions for advanced functionality
Code Comparison
Flask (basic route):
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
Flask-AppBuilder (basic view):
from flask_appbuilder import AppBuilder, BaseView, expose
class MyView(BaseView):
@expose('/')
def method1(self):
return "Hello World!"
appbuilder.add_view(MyView(), "My View")
Flask-AppBuilder provides a more structured approach with built-in views and admin interfaces, while Flask offers a simpler, more flexible foundation for custom development. Flask-AppBuilder includes additional features like user management and security out of the box, whereas Flask requires manual implementation or additional extensions for such functionality. Flask's simplicity makes it easier to learn and customize, while Flask-AppBuilder's pre-built components can accelerate development for certain types of applications.
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Pros of FastAPI
- Significantly faster performance due to asynchronous capabilities
- Built-in API documentation with Swagger UI and ReDoc
- Type hints and data validation out of the box
Cons of FastAPI
- Steeper learning curve for developers new to async programming
- Less mature ecosystem compared to Flask-based frameworks
- Fewer built-in admin and authentication features
Code Comparison
FastAPI:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Flask-AppBuilder:
from flask import Flask
from flask_appbuilder import AppBuilder
app = Flask(__name__)
AppBuilder(app)
@app.route('/')
def hello():
return "Hello World!"
FastAPI offers a more modern, type-hinted approach with async support, while Flask-AppBuilder provides a more traditional Flask-based structure with additional built-in features for rapid application development. FastAPI excels in API-focused projects, whereas Flask-AppBuilder is better suited for admin-heavy applications with its pre-built components and security model.
The Web framework for perfectionists with deadlines.
Pros of Django
- More comprehensive and feature-rich web framework
- Larger community and ecosystem with extensive third-party packages
- Built-in admin interface for quick backend management
Cons of Django
- Steeper learning curve for beginners
- Less flexibility in project structure compared to Flask-based frameworks
- Heavier and potentially slower for small-scale applications
Code Comparison
Django (models.py):
from django.db import models
class User(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField(unique=True)
Flask-AppBuilder (models.py):
from flask_appbuilder import Model
from sqlalchemy import Column, Integer, String
class User(Model):
id = Column(Integer, primary_key=True)
name = Column(String(100), nullable=False)
email = Column(String(120), unique=True, nullable=False)
Both frameworks use an ORM for database interactions, but Django's built-in ORM is more tightly integrated with the framework, while Flask-AppBuilder uses SQLAlchemy. Django's model definition is more concise, but Flask-AppBuilder offers more explicit control over column types and constraints.
Django is generally better suited for large, complex projects with many built-in features, while Flask-AppBuilder provides a more lightweight and flexible approach for smaller to medium-sized applications that require rapid development and customization.
Web APIs for Django. 🎸
Pros of Django REST Framework
- More mature and widely adopted in the Django ecosystem
- Extensive documentation and community support
- Flexible serialization system for complex data structures
Cons of Django REST Framework
- Steeper learning curve for beginners
- Tighter coupling with Django, less suitable for non-Django projects
- Can be overkill for simple API needs
Code Comparison
Django REST Framework:
from rest_framework import serializers
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ['id', 'username', 'email']
Flask-AppBuilder:
from flask_appbuilder.models.sqla.interface import SQLAInterface
class UserModelView(ModelView):
datamodel = SQLAInterface(User)
list_columns = ['id', 'username', 'email']
Both frameworks provide ways to define model-based views, but Django REST Framework uses serializers for data transformation, while Flask-AppBuilder uses a more direct approach with SQLAInterface.
Django REST Framework offers more flexibility in handling complex data structures and relationships, making it suitable for larger projects with intricate API requirements. Flask-AppBuilder, on the other hand, provides a simpler and more straightforward approach, which can be beneficial for smaller projects or those requiring rapid development.
Ready-to-use and customizable users management for FastAPI
Pros of fastapi-users
- Built specifically for FastAPI, offering seamless integration and better performance
- Provides more modern authentication methods like JWT and OAuth2
- Lighter weight and more focused on user management functionality
Cons of fastapi-users
- Less comprehensive admin interface compared to Flask-AppBuilder
- Smaller community and ecosystem, potentially leading to fewer resources and extensions
- May require more custom development for complex applications
Code Comparison
Flask-AppBuilder:
from flask_appbuilder import AppBuilder, SQLA
db = SQLA(app)
appbuilder = AppBuilder(app, db.session)
fastapi-users:
from fastapi_users import FastAPIUsers
from fastapi_users.authentication import JWTAuthentication
fastapi_users = FastAPIUsers(
user_db,
[JWTAuthentication(secret="SECRET", lifetime_seconds=3600)],
)
Flask-AppBuilder provides a more comprehensive setup with built-in admin interface, while fastapi-users focuses on user management and authentication, requiring additional setup for admin functionality.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Flask App Builder
.. image:: https://github.com/dpgaspar/Flask-AppBuilder/workflows/Python/badge.svg :target: https://github.com/dpgaspar/Flask-AppBuilder/actions
.. image:: https://img.shields.io/pypi/v/Flask-AppBuilder.svg :alt: PyPI :target: https://pypi.org/project/Flask-AppBuilder/
.. image:: https://img.shields.io/badge/pyversions-3.8%2C%203.9%2C%203.10%2C%203.11%2C%203.12-blue.svg :target: https://www.python.org/
.. image:: https://codecov.io/github/dpgaspar/Flask-AppBuilder/coverage.svg?branch=master :target: https://codecov.io/github/dpgaspar/Flask-AppBuilder
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black
Simple and rapid application development framework, built on top of Flask <http://flask.pocoo.org/>
_.
includes detailed security, auto CRUD generation for your models, google charts and much more.
Extensive configuration of all functionality, easily integrate with normal Flask/Jinja2 development.
-
Documentation:
Documentation <http://flask-appbuilder.readthedocs.org/en/latest/>
_ -
Mailing list:
Google group <https://groups.google.com/forum/#!forum/flask-appbuilder>
_ -
Chat:
Gitter <https://gitter.im/dpgaspar/Flask-AppBuilder>
_ -
Examples:
examples <https://github.com/dpgaspar/Flask-AppBuilder/tree/master/examples>
_
Checkout installation video on YouTube <http://youtu.be/xvum4vfwldg>
_
Quick how to Demo from the docs <http://flaskappbuilder.pythonanywhere.com/>
_ (login has guest/welcome).
Change Log
Versions <https://github.com/dpgaspar/Flask-AppBuilder/tree/master/CHANGELOG.rst>
_ for further detail on what changed.
Fixes, Bugs and contributions
You're welcome to report bugs, propose new features, or even better contribute to this project.
Issues, bugs and new features <https://github.com/dpgaspar/Flask-AppBuilder/issues/new>
_
Contribute <https://github.com/dpgaspar/Flask-AppBuilder/fork>
_
Includes:
- Database
- SQLAlchemy, multiple database support: sqlite, MySQL, ORACLE, MSSQL, DB2 etc.
- Partial support for MongoDB using MongoEngine.
- Multiple database connections support (Vertical partitioning).
- Easy mixin audit to models (created/changed by user, and timestamps).
- Security
- Automatic permissions lookup, based on exposed methods. It will grant all permissions to the Admin Role.
- Inserts on the Database all the detailed permissions possible on your application.
- Public (no authentication needed) and Private permissions.
- Role based permissions.
- Authentication support for OAuth, OpenID, Database, LDAP and REMOTE_USER environ var.
- Support for self user registration.
- Views and Widgets
- Automatic menu generation.
- Automatic CRUD generation.
- Multiple actions on db records.
- Big variety of filters for your lists.
- Various view widgets: lists, master-detail, list of thumbnails etc
- Select2, Datepicker, DateTimePicker
- Related Select2 fields.
- Google charts with automatic group by or direct values and filters.
- AddOn system, write your own and contribute.
- CRUD REST API
- Automatic CRUD RESTful APIs.
- Internationalization
- Integration with flask-jwt-extended extension to protect your endpoints.
- Metadata for dynamic rendering.
- Selectable columns and metadata keys.
- Automatic and configurable data validation.
- Forms
- Automatic, Add, Edit and Show from Database Models
- Labels and descriptions for each field.
- Automatic base validators from model's definition.
- Custom validators, extra fields, custom filters for related dropdown lists.
- Image and File support for upload and database field association. It will handle everything for you.
- Field sets for Form's (Django style).
- i18n
- Support for multi-language via Babel
- Bootstrap 3.1.1 CSS and js, with Select2 and DatePicker
- Font-Awesome icons, for menu icons and actions.
Some pictures
Login page (with AUTH_DB)
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/login_db.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/login_db.png
Login page (with AUTH_OAUTH)
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/login_oauth.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/login_oauth.png
Security
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/security.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/security.png
Lists:
List contacts example
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/contact_list.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/contact_list.png
List Group example with search
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/group_list.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/group_list.png
Charts:
Group by pie chart
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/grouped_chart.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/grouped_chart.png
Direct time chart
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/direct_chart.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/chart_time1.png
Group by time chart
.. image:: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/chart_time2.png :width: 480px :target: https://raw.github.com/dpgaspar/flask-AppBuilder/master/images/chart_time2.png
Projects/Organizations using FAB
If you would like to share your project, or let everyone know that you're using FAB on your organization please submit a PR or send me an email with the details.
Projects:
-
Superset <https://github.com/apache/incubator-superset>
_ - a data exploration platform designed to be visual, intuitive, and interactive -
Airflow <https://github.com/apache/airflow>
_ - a platform to programmatically author, schedule, and monitor workflows.
Organizations:
- Miniclip
- EuroBIC
On Beat Digital <https://onbeat.digital/>
_
Depends on:
- flask
- click
- colorama
- flask-sqlalchemy
- flask-login
- flask-openid
- flask-wtform
- flask-Babel
Top Related Projects
The Python micro framework for building web applications.
FastAPI framework, high performance, easy to learn, fast to code, ready for production
The Web framework for perfectionists with deadlines.
Web APIs for Django. 🎸
Ready-to-use and customizable users management for FastAPI
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot