|
| 1 | +# [Flask Dashboard](https://appseed.us/admin-dashboards/flask) Now UI |
| 2 | + |
| 3 | +[Admin dashboard](https://appseed.us/admin-dashboards) generated by AppSeed in **Flask** Framework. |
| 4 | + |
| 5 | +Now UI Dashboard is a responsive Bootstrap 4 kit provided for free by Invision and Creative Tim. Now UI Dashboard comes packed with all plugins that you might need inside a project and documentation on how to get started. It is light and easy to use, and also very powerful. |
| 6 | + |
| 7 | +<br /> |
| 8 | + |
| 9 | +> Features |
| 10 | +
|
| 11 | +- DBMS: SQLite, PostgreSQL (production) |
| 12 | +- DB Tools: SQLAlchemy ORM, Alembic (schema migrations) |
| 13 | +- Modular design with **Blueprints**, simple codebase |
| 14 | +- Session-Based authentication (via **flask_login**), Forms validation |
| 15 | +- Deployment scripts: Docker, Gunicorn / Nginx, Heroku |
| 16 | +- Support via **Github** and [Discord](https://discord.gg/fZC6hup). |
| 17 | + |
| 18 | +<br /> |
| 19 | + |
| 20 | +> Links |
| 21 | +
|
| 22 | +- [Flask Now UI](https://appseed.us/admin-dashboards/flask-dashboard-nowui-design) - Product page |
| 23 | +- [Flask Now UI - Demo](https://flask-now-ui-dashboard.appseed-srv1.com) - LIVE App deployment |
| 24 | +- [Flask Tutorial](https://github.com/app-generator/tutorial-flask) - Getting started with Flask |
| 25 | + |
| 26 | +<br /> |
| 27 | + |
| 28 | +## Want more? Go PRO! |
| 29 | + |
| 30 | +PRO versions include **Premium UI Kits**, Lifetime updates and **24/7 LIVE Support** (via [Discord](https://discord.gg/fZC6hup)) |
| 31 | + |
| 32 | +| [Flask Datta PRO](https://appseed.us/admin-dashboards/flask-dashboard-dattaable-pro) | [Flask Material PRO](https://appseed.us/admin-dashboards/flask-dashboard-material-pro) | [Flask Volt PRO](https://appseed.us/admin-dashboards/flask-dashboard-volt-pro) | |
| 33 | +| --- | --- | --- | |
| 34 | +| [](https://appseed.us/admin-dashboards/flask-dashboard-dattaable-pro) | [](https://appseed.us/admin-dashboards/flask-dashboard-material-pro) | [](https://appseed.us/admin-dashboards/flask-dashboard-volt-pro) |
| 35 | + |
| 36 | +<br /> |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +<br /> |
| 41 | + |
| 42 | +## How to use it |
| 43 | + |
| 44 | +```bash |
| 45 | +$ # Get the code |
| 46 | +$ git clone https://github.com/app-generator/flask-now-ui-dashboard.git |
| 47 | +$ cd flask-now-ui-dashboard |
| 48 | +$ |
| 49 | +$ # Virtualenv modules installation (Unix based systems) |
| 50 | +$ virtualenv env |
| 51 | +$ source env/bin/activate |
| 52 | +$ |
| 53 | +$ # Virtualenv modules installation (Windows based systems) |
| 54 | +$ # virtualenv env |
| 55 | +$ # .\env\Scripts\activate |
| 56 | +$ |
| 57 | +$ # Install modules - SQLite Database |
| 58 | +$ pip3 install -r requirements.txt |
| 59 | +$ |
| 60 | +$ # OR with PostgreSQL connector |
| 61 | +$ # pip install -r requirements-pgsql.txt |
| 62 | +$ |
| 63 | +$ # Set the FLASK_APP environment variable |
| 64 | +$ (Unix/Mac) export FLASK_APP=run.py |
| 65 | +$ (Windows) set FLASK_APP=run.py |
| 66 | +$ (Powershell) $env:FLASK_APP = ".\run.py" |
| 67 | +$ |
| 68 | +$ # Set up the DEBUG environment |
| 69 | +$ # (Unix/Mac) export FLASK_ENV=development |
| 70 | +$ # (Windows) set FLASK_ENV=development |
| 71 | +$ # (Powershell) $env:FLASK_ENV = "development" |
| 72 | +$ |
| 73 | +$ # Start the application (development mode) |
| 74 | +$ # --host=0.0.0.0 - expose the app on all network interfaces (default 127.0.0.1) |
| 75 | +$ # --port=5000 - specify the app port (default 5000) |
| 76 | +$ flask run --host=0.0.0.0 --port=5000 |
| 77 | +$ |
| 78 | +$ # Access the dashboard in browser: http://127.0.0.1:5000/ |
| 79 | +``` |
| 80 | + |
| 81 | +> Note: To use the app, please access the registration page and create a new user. After authentication, the app will unlock the private pages. |
| 82 | +
|
| 83 | +<br /> |
| 84 | + |
| 85 | +## Codebase structure |
| 86 | + |
| 87 | +The project is coded using blueprints, app factory pattern, dual configuration profile (development and production) and an intuitive structure presented bellow: |
| 88 | + |
| 89 | +> Simplified version |
| 90 | +
|
| 91 | +```bash |
| 92 | +< PROJECT ROOT > |
| 93 | + | |
| 94 | + |-- app/ # Implements app logic |
| 95 | + | |-- base/ # Base Blueprint - handles the authentication |
| 96 | + | |-- home/ # Home Blueprint - serve UI Kit pages |
| 97 | + | | |
| 98 | + | __init__.py # Initialize the app |
| 99 | + | |
| 100 | + |-- requirements.txt # Development modules - SQLite storage |
| 101 | + |-- requirements-mysql.txt # Production modules - Mysql DMBS |
| 102 | + |-- requirements-pqsql.txt # Production modules - PostgreSql DMBS |
| 103 | + | |
| 104 | + |-- .env # Inject Configuration via Environment |
| 105 | + |-- config.py # Set up the app |
| 106 | + |-- run.py # Start the app - WSGI gateway |
| 107 | + | |
| 108 | + |-- ************************************************************************ |
| 109 | +``` |
| 110 | + |
| 111 | +<br /> |
| 112 | + |
| 113 | +> The bootstrap flow |
| 114 | +
|
| 115 | +- `run.py` loads the `.env` file |
| 116 | +- Initialize the app using the specified profile: *Debug* or *Production* |
| 117 | + - If env.DEBUG is set to *True* the SQLite storage is used |
| 118 | + - If env.DEBUG is set to *False* the specified DB driver is used (MySql, PostgreSQL) |
| 119 | +- Call the app factory method `create_app` defined in app/__init__.py |
| 120 | +- Redirect the guest users to Login page |
| 121 | +- Unlock the pages served by *home* blueprint for authenticated users |
| 122 | + |
| 123 | +<br /> |
| 124 | + |
| 125 | +> App / Base Blueprint |
| 126 | +
|
| 127 | +The *Base* blueprint handles the authentication (routes and forms) and assets management. The structure is presented below: |
| 128 | + |
| 129 | +```bash |
| 130 | +< PROJECT ROOT > |
| 131 | + | |
| 132 | + |-- app/ |
| 133 | + | |-- home/ # Home Blueprint - serve app pages (private area) |
| 134 | + | |-- base/ # Base Blueprint - handles the authentication |
| 135 | + | |-- static/ |
| 136 | + | | |-- <css, JS, images> # CSS files, Javascripts files |
| 137 | + | | |
| 138 | + | |-- templates/ # Templates used to render pages |
| 139 | + | | |
| 140 | + | |-- includes/ # |
| 141 | + | | |-- navigation.html # Top menu component |
| 142 | + | | |-- sidebar.html # Sidebar component |
| 143 | + | | |-- footer.html # App Footer |
| 144 | + | | |-- scripts.html # Scripts common to all pages |
| 145 | + | | |
| 146 | + | |-- layouts/ # Master pages |
| 147 | + | | |-- base-fullscreen.html # Used by Authentication pages |
| 148 | + | | |-- base.html # Used by common pages |
| 149 | + | | |
| 150 | + | |-- accounts/ # Authentication pages |
| 151 | + | |-- login.html # Login page |
| 152 | + | |-- register.html # Registration page |
| 153 | + | |
| 154 | + |-- requirements.txt # Development modules - SQLite storage |
| 155 | + |-- requirements-mysql.txt # Production modules - Mysql DMBS |
| 156 | + |-- requirements-pqsql.txt # Production modules - PostgreSql DMBS |
| 157 | + | |
| 158 | + |-- .env # Inject Configuration via Environment |
| 159 | + |-- config.py # Set up the app |
| 160 | + |-- run.py # Start the app - WSGI gateway |
| 161 | + | |
| 162 | + |-- ************************************************************************ |
| 163 | +``` |
| 164 | + |
| 165 | +<br /> |
| 166 | + |
| 167 | +> App / Home Blueprint |
| 168 | +
|
| 169 | +The *Home* blueprint handles UI Kit pages for authenticated users. This is the private zone of the app - the structure is presented below: |
| 170 | + |
| 171 | +```bash |
| 172 | +< PROJECT ROOT > |
| 173 | + | |
| 174 | + |-- app/ |
| 175 | + | |-- base/ # Base Blueprint - handles the authentication |
| 176 | + | |-- home/ # Home Blueprint - serve app pages (private area) |
| 177 | + | | |
| 178 | + | |-- templates/ # UI Kit Pages |
| 179 | + | | |
| 180 | + | |-- index.html # Default page |
| 181 | + | |-- page-404.html # Error 404 - mandatory page |
| 182 | + | |-- page-500.html # Error 500 - mandatory page |
| 183 | + | |-- page-403.html # Error 403 - mandatory page |
| 184 | + | |-- *.html # All other HTML pages |
| 185 | + | |
| 186 | + |-- requirements.txt # Development modules - SQLite storage |
| 187 | + |-- requirements-mysql.txt # Production modules - Mysql DMBS |
| 188 | + |-- requirements-pqsql.txt # Production modules - PostgreSql DMBS |
| 189 | + | |
| 190 | + |-- .env # Inject Configuration via Environment |
| 191 | + |-- config.py # Set up the app |
| 192 | + |-- run.py # Start the app - WSGI gateway |
| 193 | + | |
| 194 | + |-- ************************************************************************ |
| 195 | +``` |
| 196 | + |
| 197 | +<br /> |
| 198 | + |
| 199 | +## Deployment |
| 200 | + |
| 201 | +The app is provided with a basic configuration to be executed in [Docker](https://www.docker.com/), [Heroku](https://www.heroku.com/), [Gunicorn](https://gunicorn.org/), and [Waitress](https://docs.pylonsproject.org/projects/waitress/en/stable/). |
| 202 | + |
| 203 | +<br /> |
| 204 | + |
| 205 | +### [Docker](https://www.docker.com/) execution |
| 206 | +--- |
| 207 | + |
| 208 | +The application can be easily executed in a docker container. The steps: |
| 209 | + |
| 210 | +> Get the code |
| 211 | +
|
| 212 | +```bash |
| 213 | +$ git clone https://github.com/app-generator/flask-now-ui-dashboard.git |
| 214 | +$ cd flask-now-ui-dashboard |
| 215 | +``` |
| 216 | + |
| 217 | +> Start the app in Docker |
| 218 | +
|
| 219 | +```bash |
| 220 | +$ sudo docker-compose pull && sudo docker-compose build && sudo docker-compose up -d |
| 221 | +``` |
| 222 | + |
| 223 | +Visit `http://localhost:5005` in your browser. The app should be up & running. |
| 224 | + |
| 225 | +<br /> |
| 226 | + |
| 227 | +### [Heroku](https://www.heroku.com/) |
| 228 | +--- |
| 229 | + |
| 230 | +Steps to deploy on **Heroku** |
| 231 | + |
| 232 | +- [Create a FREE account](https://signup.heroku.com/) on Heroku platform |
| 233 | +- [Install the Heroku CLI](https://devcenter.heroku.com/articles/getting-started-with-python#set-up) that match your OS: Mac, Unix or Windows |
| 234 | +- Open a terminal window and authenticate via `heroku login` command |
| 235 | +- Clone the sources and push the project for LIVE deployment |
| 236 | + |
| 237 | +```bash |
| 238 | +$ # Clone the source code: |
| 239 | +$ git clone https://github.com/app-generator/flask-now-ui-dashboard.git |
| 240 | +$ cd flask-now-ui-dashboard |
| 241 | +$ |
| 242 | +$ # Check Heroku CLI is installed |
| 243 | +$ heroku -v |
| 244 | +heroku/7.25.0 win32-x64 node-v12.13.0 # <-- All good |
| 245 | +$ |
| 246 | +$ # Check Heroku CLI is installed |
| 247 | +$ heroku login |
| 248 | +$ # this commaond will open a browser window - click the login button (in browser) |
| 249 | +$ |
| 250 | +$ # Create the Heroku project |
| 251 | +$ heroku create |
| 252 | +$ |
| 253 | +$ # Trigger the LIVE deploy |
| 254 | +$ git push heroku master |
| 255 | +$ |
| 256 | +$ # Open the LIVE app in browser |
| 257 | +$ heroku open |
| 258 | +``` |
| 259 | + |
| 260 | +<br /> |
| 261 | + |
| 262 | +### [Gunicorn](https://gunicorn.org/) |
| 263 | +--- |
| 264 | + |
| 265 | +Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. |
| 266 | + |
| 267 | +> Install using pip |
| 268 | +
|
| 269 | +```bash |
| 270 | +$ pip install gunicorn |
| 271 | +``` |
| 272 | +> Start the app using gunicorn binary |
| 273 | +
|
| 274 | +```bash |
| 275 | +$ gunicorn --bind 0.0.0.0:8001 run:app |
| 276 | +Serving on http://localhost:8001 |
| 277 | +``` |
| 278 | + |
| 279 | +Visit `http://localhost:8001` in your browser. The app should be up & running. |
| 280 | + |
| 281 | +<br /> |
| 282 | + |
| 283 | +### [Waitress](https://docs.pylonsproject.org/projects/waitress/en/stable/) |
| 284 | +--- |
| 285 | + |
| 286 | +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. |
| 287 | + |
| 288 | +> Install using pip |
| 289 | +
|
| 290 | +```bash |
| 291 | +$ pip install waitress |
| 292 | +``` |
| 293 | +> Start the app using [waitress-serve](https://docs.pylonsproject.org/projects/waitress/en/stable/runner.html) |
| 294 | +
|
| 295 | +```bash |
| 296 | +$ waitress-serve --port=8001 run:app |
| 297 | +Serving on http://localhost:8001 |
| 298 | +``` |
| 299 | + |
| 300 | +Visit `http://localhost:8001` in your browser. The app should be up & running. |
| 301 | + |
| 302 | +<br /> |
| 303 | + |
| 304 | +## Credits & Links |
| 305 | + |
| 306 | +- [Flask Framework](https://www.palletsprojects.com/p/flask/) - The offcial website |
| 307 | +- [Boilerplate Code](https://appseed.us/boilerplate-code) - Index provided by **AppSeed** |
| 308 | +- [Boilerplate Code](https://github.com/app-generator/boilerplate-code) - Index published on Github |
| 309 | + |
| 310 | +<br /> |
| 311 | + |
| 312 | +--- |
| 313 | +[Flask Dashboard](https://appseed.us/admin-dashboards/flask) Now UI - Provided by **AppSeed [App Generator](https://appseed.us/app-generator)**. |
0 commit comments