项目作者: app-generator

项目描述 :
Flask Dashboard - Millenium Dark PRO Design | AppSeed
高级语言:
项目地址: git://github.com/app-generator/flask-dashboard-millenium-dark-pro.git


Flask Dashboard Millenium Dark PRO

Commercial product - Flask Dashboard coded on top of Millenium Dashboard PRO crafted by ThemeKita.


Dashboard Features

  • SQLite, PostgreSQL, SQLAlchemy ORM
  • Alembic (DB schema migrations)
  • Modular design with Blueprints
  • Session-Based authentication (via flask_login)
  • Forms validation
  • Deployment scripts: Docker, Gunicorn / Nginx
  • Sample UI Kit: Millenium Dashboard PRO provided by ThemeKita
  • Commercial License
  • 24/7 Live Support via Discord.

Links


Flask Dashboard Millenium Dark PRO - Admin Panel coded in Flask.


How to use it

  1. $ # Get the code
  2. $ git clone https://github.com/app-generator/priv-flask-dashboard-millenium-dark-pro.git
  3. $ cd priv-flask-dashboard-millenium-dark-pro
  4. $
  5. $ # Virtualenv modules installation (Unix based systems)
  6. $ virtualenv env
  7. $ source env/bin/activate
  8. $
  9. $ # Virtualenv modules installation (Windows based systems)
  10. $ # virtualenv env
  11. $ # .\env\Scripts\activate
  12. $
  13. $ # Install modules - SQLite Database
  14. $ pip3 install -r requirements.txt
  15. $
  16. $ # OR with PostgreSQL connector
  17. $ # pip install -r requirements-pgsql.txt
  18. $
  19. $ # Set the FLASK_APP environment variable
  20. $ (Unix/Mac) export FLASK_APP=run.py
  21. $ (Windows) set FLASK_APP=run.py
  22. $ (Powershell) $env:FLASK_APP = ".\run.py"
  23. $
  24. $ # Set up the DEBUG environment
  25. $ # (Unix/Mac) export FLASK_ENV=development
  26. $ # (Windows) set FLASK_ENV=development
  27. $ # (Powershell) $env:FLASK_ENV = "development"
  28. $
  29. $ # Start the application (development mode)
  30. $ # --host=0.0.0.0 - expose the app on all network interfaces (default 127.0.0.1)
  31. $ # --port=5000 - specify the app port (default 5000)
  32. $ flask run --host=0.0.0.0 --port=5000
  33. $
  34. $ # Access the dashboard in browser: http://127.0.0.1:5000/

Note: To use the app, please access the registration page and create a new user. After authentication, the app will unlock the private pages.


Code-base structure

The project is coded using blueprints, app factory pattern, dual configuration profile (development and production) and an intuitive structure presented bellow:

Simplified version

  1. < PROJECT ROOT >
  2. |
  3. |-- app/ # Implements app logic
  4. | |-- base/ # Base Blueprint - handles the authentication
  5. | |-- home/ # Home Blueprint - serve UI Kit pages
  6. | |
  7. | __init__.py # Initialize the app
  8. |
  9. |-- requirements.txt # Development modules - SQLite storage
  10. |-- requirements-mysql.txt # Production modules - Mysql DMBS
  11. |-- requirements-pqsql.txt # Production modules - PostgreSql DMBS
  12. |
  13. |-- .env # Inject Configuration via Environment
  14. |-- config.py # Set up the app
  15. |-- run.py # Start the app - WSGI gateway
  16. |
  17. |-- ************************************************************************


The bootstrap flow

  • run.py loads the .env file
  • Initialize the app using the specified profile: Debug or Production
    • If env.DEBUG is set to True the SQLite storage is used
    • If env.DEBUG is set to False the specified DB driver is used (MySql, PostgreSQL)
  • Call the app factory method create_app defined in app/init.py
  • Redirect the guest users to Login page
  • Unlock the pages served by home blueprint for authenticated users


App / Base Blueprint

The Base blueprint handles the authentication (routes and forms) and assets management. The structure is presented below:

  1. < PROJECT ROOT >
  2. |
  3. |-- app/
  4. | |-- home/ # Home Blueprint - serve app pages (private area)
  5. | |-- base/ # Base Blueprint - handles the authentication
  6. | |-- static/
  7. | | |-- <css, JS, images> # CSS files, Javascripts files
  8. | |
  9. | |-- templates/ # Templates used to render pages
  10. | |
  11. | |-- includes/ #
  12. | | |-- navigation.html # Top menu component
  13. | | |-- sidebar.html # Sidebar component
  14. | | |-- footer.html # App Footer
  15. | | |-- scripts.html # Scripts common to all pages
  16. | |
  17. | |-- layouts/ # Master pages
  18. | | |-- base-fullscreen.html # Used by Authentication pages
  19. | | |-- base.html # Used by common pages
  20. | |
  21. | |-- accounts/ # Authentication pages
  22. | |-- login.html # Login page
  23. | |-- register.html # Registration page
  24. |
  25. |-- requirements.txt # Development modules - SQLite storage
  26. |-- requirements-mysql.txt # Production modules - Mysql DMBS
  27. |-- requirements-pqsql.txt # Production modules - PostgreSql DMBS
  28. |
  29. |-- .env # Inject Configuration via Environment
  30. |-- config.py # Set up the app
  31. |-- run.py # Start the app - WSGI gateway
  32. |
  33. |-- ************************************************************************


App / Home Blueprint

The Home blueprint handles UI Kit pages for authenticated users. This is the private zone of the app - the structure is presented below:

  1. < PROJECT ROOT >
  2. |
  3. |-- app/
  4. | |-- base/ # Base Blueprint - handles the authentication
  5. | |-- home/ # Home Blueprint - serve app pages (private area)
  6. | |
  7. | |-- templates/ # UI Kit Pages
  8. | |
  9. | |-- index.html # Default page
  10. | |-- page-404.html # Error 404 page
  11. | |-- page-500.html # Error 500 page
  12. | |-- page-403.html # Error 403 page
  13. | |-- *.html # All other HTML pages
  14. |
  15. |-- requirements.txt # Development modules - SQLite storage
  16. |-- requirements-mysql.txt # Production modules - Mysql DMBS
  17. |-- requirements-pqsql.txt # Production modules - PostgreSql DMBS
  18. |
  19. |-- .env # Inject Configuration via Environment
  20. |-- config.py # Set up the app
  21. |-- run.py # Start the app - WSGI gateway
  22. |
  23. |-- ************************************************************************


Deployment

The app is provided with a basic configuration to be executed in Docker, Gunicorn, and Waitress.


Docker execution


The application can be easily executed in a docker container. The steps:

Get the code

  1. $ git clone https://github.com/app-generator/priv-flask-dashboard-millenium-dark-pro.git
  2. $ cd priv-flask-dashboard-millenium-dark-pro

Start the app in Docker

  1. $ sudo docker-compose pull && sudo docker-compose build && sudo docker-compose up -d

Visit http://localhost:5005 in your browser. The app should be up & running.


Gunicorn


Gunicorn ‘Green Unicorn’ is a Python WSGI HTTP Server for UNIX.

Install using pip

  1. $ pip install gunicorn

Start the app using gunicorn binary

  1. $ gunicorn --bind 0.0.0.0:8001 run:app
  2. Serving on http://localhost:8001

Visit http://localhost:8001 in your browser. The app should be up & running.


Waitress


Waitress (Gunicorn equivalent for Windows) is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones that live in the Python standard library.

Install using pip

  1. $ pip install waitress

Start the app using waitress-serve

  1. $ waitress-serve --port=8001 run:app
  2. Serving on http://localhost:8001

Visit http://localhost:8001 in your browser. The app should be up & running.




Flask Dashboard Millenium Dark PRO - Provided by AppSeed Web App Generator.