|
1 | | -# boilerplate-code-flask-dashboard |
| 1 | +# [Flask Dashboard Boilerplate](https://appseed.us/boilerplate-code/flask-dashboard/) |
| 2 | + |
| 3 | +Reference codebase used by `AppSeed` in all [Flask Dashboard](https://appseed.us/admin-dashboards/flask/) starters - the product uses an amazing design crafted by CodedThemes. |
| 4 | + |
| 5 | +- 👉 [Flask Boilerplate](https://appseed.us/boilerplate-code/flask-dashboard/) - `Product page` |
| 6 | +- 👉 [Flask Boilerplate](https://flask-datta-able.appseed-srv1.com/) - `LIVE App` |
| 7 | +- 👉 Free [Support](https://appseed.us/support/) via `Email` & `Discord` |
| 8 | + |
| 9 | +<br /> |
| 10 | + |
| 11 | +> 🚀 Built with [App Generator](https://appseed.us/generator), timestamp `2022-06-23 18:20` |
| 12 | +
|
| 13 | +- ✅ `Up-to-date dependencies` |
| 14 | +- ✅ `Database`: `SQLite`, MySql |
| 15 | + - Silent fallback to `SQLite` |
| 16 | +- ✅ `DB Tools`: SQLAlchemy ORM, `Flask-Migrate` |
| 17 | +- ✅ `Authentication`, Session Based, `OAuth` via **Github** |
| 18 | +- ✅ Docker, `Flask-Minify` (page compression) |
| 19 | +- 🚀 `Deployment` |
| 20 | + - `CI/CD` flow via `Render` |
| 21 | + - [Flask Datta Able - Go LIVE](https://www.youtube.com/watch?v=ZpKy2j9UU84) (`video presentation`) |
| 22 | + |
| 23 | +<br /> |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +<br /> |
| 28 | + |
| 29 | +## Start with `Docker` |
| 30 | + |
| 31 | +> 👉 **Step 1** - Download the code |
| 32 | +
|
| 33 | +```bash |
| 34 | +$ git clone https://github.com/app-generator/boilerplate-code-flask-dashboard.git |
| 35 | +$ cd boilerplate-code-flask-dashboard |
| 36 | +``` |
| 37 | + |
| 38 | +<br /> |
| 39 | + |
| 40 | +> 👉 **Step 2** - Start the APP in `Docker` |
| 41 | +
|
| 42 | +```bash |
| 43 | +$ docker-compose up --build |
| 44 | +``` |
| 45 | + |
| 46 | +Visit `http://localhost:5085` in your browser. The app should be up & running. |
| 47 | + |
| 48 | +<br /> |
| 49 | + |
| 50 | +### Create `.env` from `env.sample` |
| 51 | + |
| 52 | +The meaning of each variable can be found below: |
| 53 | + |
| 54 | +- `DEBUG`: if `True` the app runs in develoment mode |
| 55 | + - For production value `False` should be used |
| 56 | +- `ASSETS_ROOT`: used in assets management |
| 57 | + - default value: `/static/assets` |
| 58 | + |
| 59 | +<br /> |
| 60 | + |
| 61 | +## Manual Build |
| 62 | + |
| 63 | +> Download the code |
| 64 | +
|
| 65 | +```bash |
| 66 | +$ git clone https://github.com/app-generator/boilerplate-code-flask-dashboard.git |
| 67 | +$ cd boilerplate-code-flask-dashboard |
| 68 | +``` |
| 69 | + |
| 70 | +<br /> |
| 71 | + |
| 72 | +### 👉 Set Up for `Unix`, `MacOS` |
| 73 | + |
| 74 | +> Install modules via `VENV` |
| 75 | +
|
| 76 | +```bash |
| 77 | +$ virtualenv env |
| 78 | +$ source env/bin/activate |
| 79 | +$ pip install -r requirements.txt |
| 80 | +``` |
| 81 | + |
| 82 | +<br /> |
| 83 | + |
| 84 | +> Set Up Flask Environment |
| 85 | +
|
| 86 | +```bash |
| 87 | +$ export FLASK_APP=run.py |
| 88 | +$ export FLASK_ENV=development |
| 89 | +``` |
| 90 | + |
| 91 | +<br /> |
| 92 | + |
| 93 | +> Start the app |
| 94 | +
|
| 95 | +```bash |
| 96 | +$ flask run |
| 97 | +// OR |
| 98 | +$ flask run --cert=adhoc # For HTTPS server |
| 99 | +``` |
| 100 | + |
| 101 | +At this point, the app runs at `http://127.0.0.1:5000/`. |
| 102 | + |
| 103 | +<br /> |
| 104 | + |
| 105 | +### 👉 Set Up for `Windows` |
| 106 | + |
| 107 | +> Install modules via `VENV` (windows) |
| 108 | +
|
| 109 | +``` |
| 110 | +$ virtualenv env |
| 111 | +$ .\env\Scripts\activate |
| 112 | +$ pip install -r requirements.txt |
| 113 | +``` |
| 114 | + |
| 115 | +<br /> |
| 116 | + |
| 117 | +> Set Up Flask Environment |
| 118 | +
|
| 119 | +```bash |
| 120 | +$ # CMD |
| 121 | +$ set FLASK_APP=run.py |
| 122 | +$ set FLASK_ENV=development |
| 123 | +$ |
| 124 | +$ # Powershell |
| 125 | +$ $env:FLASK_APP = ".\run.py" |
| 126 | +$ $env:FLASK_ENV = "development" |
| 127 | +``` |
| 128 | + |
| 129 | +<br /> |
| 130 | + |
| 131 | +> Start the app |
| 132 | +
|
| 133 | +```bash |
| 134 | +$ flask run |
| 135 | +// OR |
| 136 | +$ flask run --cert=adhoc # For HTTPS server |
| 137 | +``` |
| 138 | + |
| 139 | +At this point, the app runs at `http://127.0.0.1:5000/`. |
| 140 | + |
| 141 | +<br /> |
| 142 | + |
| 143 | +### 👉 Create Users |
| 144 | + |
| 145 | +By default, the app redirects guest users to authenticate. In order to access the private pages, follow this set up: |
| 146 | + |
| 147 | +- Start the app via `flask run` |
| 148 | +- Access the `registration` page and create a new user: |
| 149 | + - `http://127.0.0.1:5000/register` |
| 150 | +- Access the `sign in` page and authenticate |
| 151 | + - `http://127.0.0.1:5000/login` |
| 152 | + |
| 153 | +<br /> |
| 154 | + |
| 155 | +## Codebase Structure |
| 156 | + |
| 157 | +The project is coded using blueprints, app factory pattern, dual configuration profile (development and production) and an intuitive structure presented bellow: |
| 158 | + |
| 159 | +```bash |
| 160 | +< PROJECT ROOT > |
| 161 | + | |
| 162 | + |-- apps/ |
| 163 | + | | |
| 164 | + | |-- home/ # A simple app that serve HTML files |
| 165 | + | | |-- routes.py # Define app routes |
| 166 | + | | |
| 167 | + | |-- authentication/ # Handles auth routes (login and register) |
| 168 | + | | |-- routes.py # Define authentication routes |
| 169 | + | | |-- models.py # Defines models |
| 170 | + | | |-- forms.py # Define auth forms (login and register) |
| 171 | + | | |
| 172 | + | |-- static/ |
| 173 | + | | |-- <css, JS, images> # CSS files, Javascripts files |
| 174 | + | | |
| 175 | + | |-- templates/ # Templates used to render pages |
| 176 | + | | |-- includes/ # HTML chunks and components |
| 177 | + | | | |-- navigation.html # Top menu component |
| 178 | + | | | |-- sidebar.html # Sidebar component |
| 179 | + | | | |-- footer.html # App Footer |
| 180 | + | | | |-- scripts.html # Scripts common to all pages |
| 181 | + | | | |
| 182 | + | | |-- layouts/ # Master pages |
| 183 | + | | | |-- base-fullscreen.html # Used by Authentication pages |
| 184 | + | | | |-- base.html # Used by common pages |
| 185 | + | | | |
| 186 | + | | |-- accounts/ # Authentication pages |
| 187 | + | | | |-- login.html # Login page |
| 188 | + | | | |-- register.html # Register page |
| 189 | + | | | |
| 190 | + | | |-- home/ # UI Kit Pages |
| 191 | + | | |-- index.html # Index page |
| 192 | + | | |-- 404-page.html # 404 page |
| 193 | + | | |-- *.html # All other pages |
| 194 | + | | |
| 195 | + | config.py # Set up the app |
| 196 | + | __init__.py # Initialize the app |
| 197 | + | |
| 198 | + |-- requirements.txt # App Dependencies |
| 199 | + | |
| 200 | + |-- .env # Inject Configuration via Environment |
| 201 | + |-- run.py # Start the app - WSGI gateway |
| 202 | + | |
| 203 | + |-- ************************************************************************ |
| 204 | +``` |
| 205 | + |
| 206 | +<br /> |
| 207 | + |
| 208 | +--- |
| 209 | +[Flask Dashboard Boilerplate](https://appseed.us/boilerplate-code/flask-dashboard/) - Open-source starter generated by **[App Generator](https://appseed.us/generator/)**. |
0 commit comments