|
| 1 | +# [Flask Material Kit](https://appseed.us/apps/flask-apps/flask-material-kit) |
| 2 | + |
| 3 | +`Open-Source` seed project generated by AppSeed in **[Flask](https://appseed.us/admin-dashboards/flask)** Framework on top of **[Material Kit](https://appseed.us/apps/flask-apps/flask-material-kit)** design. Designed for those who like bold elements and beautiful websites, **Material Kit 2** is ready to help you create stunning websites and web apps. `Material Kit 2` is built with over 60 frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining. |
| 4 | + |
| 5 | +<br /> |
| 6 | + |
| 7 | +> Features: |
| 8 | +
|
| 9 | +- `Up-to-date dependencies` |
| 10 | +- [SCSS compilation](#recompile-css) via **Gulp** |
| 11 | +- UI Kit: **Material Kit - v3.0.0** (Bootstrap 5 Version) by **Creative-Tim** |
| 12 | +- SQLite database, Flask-SQLAlchemy ORM |
| 13 | +- Session-Based auth flow (login, register) |
| 14 | +- `Deployment`: **Docker**, Gunicorn / Nginx, Heroku |
| 15 | +- Support via **Github** (issues tracker) and [Discord](https://discord.gg/fZC6hup). |
| 16 | + |
| 17 | +<br /> |
| 18 | + |
| 19 | +> Links |
| 20 | +
|
| 21 | +- 👉 [Flask Material Kit](https://appseed.us/apps/flask-apps/flask-material-kit) - product page |
| 22 | +- 👉 [Flask Material Kit](https://flask-material-kit.appseed-srv1.com) - LIVE Demo |
| 23 | +- 👉 More [Flask Apps](https://appseed.us/apps/flask-apps) - provided by AppSeed |
| 24 | + |
| 25 | +<br /> |
| 26 | + |
| 27 | +## ✨ Quick Start in `Docker` |
| 28 | + |
| 29 | +> Get the code |
| 30 | +
|
| 31 | +```bash |
| 32 | +$ git clone https://github.com/app-generator/flask-material-kit.git |
| 33 | +$ cd flask-material-kit |
| 34 | +``` |
| 35 | + |
| 36 | +> Start the app in Docker |
| 37 | +
|
| 38 | +```bash |
| 39 | +$ docker-compose up --build |
| 40 | +``` |
| 41 | + |
| 42 | +Visit `http://localhost:85` in your browser. The app should be up & running. |
| 43 | + |
| 44 | +<br /> |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +<br /> |
| 49 | + |
| 50 | +## ✨ Build from sources |
| 51 | + |
| 52 | +```bash |
| 53 | +$ # Clone the sources |
| 54 | +$ git clone https://github.com/app-generator/flask-material-kit.git |
| 55 | +$ cd flask-material-kit |
| 56 | +$ |
| 57 | +$ # Virtualenv modules installation (Unix based systems) |
| 58 | +$ virtualenv env |
| 59 | +$ source env/bin/activate |
| 60 | +$ |
| 61 | +$ # Virtualenv modules installation (Windows based systems) |
| 62 | +$ # virtualenv env |
| 63 | +$ # .\env\Scripts\activate |
| 64 | +$ |
| 65 | +$ # Install requirements |
| 66 | +$ pip3 install -r requirements.txt |
| 67 | +$ |
| 68 | +$ # Set the FLASK_APP environment variable |
| 69 | +$ (Unix/Mac) export FLASK_APP=run.py |
| 70 | +$ (Windows) set FLASK_APP=run.py |
| 71 | +$ (Powershell) $env:FLASK_APP = ".\run.py" |
| 72 | +$ |
| 73 | +$ # Set up the DEBUG environment |
| 74 | +$ # (Unix/Mac) export FLASK_ENV=development |
| 75 | +$ # (Windows) set FLASK_ENV=development |
| 76 | +$ # (Powershell) $env:FLASK_ENV = "development" |
| 77 | +$ |
| 78 | +$ # Run the application |
| 79 | +$ # --host=0.0.0.0 - expose the app on all network interfaces (default 127.0.0.1) |
| 80 | +$ # --port=5000 - specify the app port (default 5000) |
| 81 | +$ flask run --host=0.0.0.0 --port=5000 |
| 82 | +$ |
| 83 | +$ # Access the app in browser: http://127.0.0.1:5000/ |
| 84 | +``` |
| 85 | + |
| 86 | +> Note: To use the app, please access the registration page and create a new user. After authentication, the app will unlock the private pages. |
| 87 | +
|
| 88 | +<br /> |
| 89 | + |
| 90 | +## ✨ Code-base structure |
| 91 | + |
| 92 | +The project has a super simple structure, represented as bellow: |
| 93 | + |
| 94 | +```bash |
| 95 | +< PROJECT ROOT > |
| 96 | + | |
| 97 | + |-- app/ |
| 98 | + | |-- static/ |
| 99 | + | | |-- <css, JS, images> # CSS files, Javascripts files |
| 100 | + | | |
| 101 | + | |-- templates/ |
| 102 | + | | | |
| 103 | + | | |-- includes/ # Page chunks, components |
| 104 | + | | | | |
| 105 | + | | | |-- navigation.html # Top bar |
| 106 | + | | | |-- sidebar.html # Left sidebar |
| 107 | + | | | |-- scripts.html # JS scripts common to all pages |
| 108 | + | | | |-- footer.html # The common footer |
| 109 | + | | | |
| 110 | + | | |-- layouts/ # App Layouts (the master pages) |
| 111 | + | | | | |
| 112 | + | | | |-- base.html # Used by common pages like index, UI |
| 113 | + | | | |-- base-fullscreen.html # Used by auth pages (login, register) |
| 114 | + | | | |
| 115 | + | | |-- accounts/ # Auth Pages (login, register) |
| 116 | + | | | | |
| 117 | + | | | |-- login.html # Use layout `base-fullscreen.html` |
| 118 | + | | | |-- register.html # Use layout `base-fullscreen.html` |
| 119 | + | | | |
| 120 | + | | |-- home/ # UI Kit Pages |
| 121 | + | | |-- index.html # Index page |
| 122 | + | | |-- 404-page.html # 404 page |
| 123 | + | | |-- *.html # All other pages |
| 124 | + | | |
| 125 | + | config.py # Provides APP Configuration |
| 126 | + | forms.py # Defines Forms (login, register) |
| 127 | + | models.py # Defines app models |
| 128 | + | views.py # Application Routes |
| 129 | + | |
| 130 | + |-- Dockerfile # Deployment |
| 131 | + |-- docker-compose.yml # Deployment |
| 132 | + |-- gunicorn-cfg.py # Deployment |
| 133 | + |-- nginx # Deployment |
| 134 | + | |-- appseed-app.conf # Deployment |
| 135 | + | |
| 136 | + |-- requirements.txt |
| 137 | + |-- run.py |
| 138 | + | |
| 139 | + |-- ************************************************************************ |
| 140 | +``` |
| 141 | + |
| 142 | +<br /> |
| 143 | + |
| 144 | +## ✨ Recompile CSS |
| 145 | + |
| 146 | +To recompile SCSS files, follow this setup: |
| 147 | + |
| 148 | +<br /> |
| 149 | + |
| 150 | +**Step #1** - Install tools |
| 151 | + |
| 152 | +- [NodeJS](https://nodejs.org/en/) 12.x or higher |
| 153 | +- [Gulp](https://gulpjs.com/) - globally |
| 154 | + - `npm install -g gulp-cli` |
| 155 | +- [Yarn](https://yarnpkg.com/) (optional) |
| 156 | + |
| 157 | +<br /> |
| 158 | + |
| 159 | +**Step #2** - Change the working directory to `assets` folder |
| 160 | + |
| 161 | +```bash |
| 162 | +$ cd app/static/assets |
| 163 | +``` |
| 164 | + |
| 165 | +<br /> |
| 166 | + |
| 167 | +**Step #3** - Install modules (this will create a classic `node_modules` directory) |
| 168 | + |
| 169 | +```bash |
| 170 | +$ npm install |
| 171 | +// OR |
| 172 | +$ yarn |
| 173 | +``` |
| 174 | + |
| 175 | +<br /> |
| 176 | + |
| 177 | +**Step #4** - Edit & Recompile SCSS files |
| 178 | + |
| 179 | +```bash |
| 180 | +$ gulp scss |
| 181 | +``` |
| 182 | + |
| 183 | +The generated file is saved in `static/assets/css` directory. |
| 184 | + |
| 185 | +<br /> |
| 186 | + |
| 187 | +## ✨ Deployment |
| 188 | + |
| 189 | +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/). |
| 190 | + |
| 191 | +### [Heroku](https://www.heroku.com/) |
| 192 | +--- |
| 193 | + |
| 194 | +Steps to deploy on **Heroku** |
| 195 | + |
| 196 | +- [Create a FREE account](https://signup.heroku.com/) on Heroku platform |
| 197 | +- [Install the Heroku CLI](https://devcenter.heroku.com/articles/getting-started-with-python#set-up) that match your OS: Mac, Unix or Windows |
| 198 | +- Open a terminal window and authenticate via `heroku login` command |
| 199 | +- Clone the sources and push the project for LIVE deployment |
| 200 | + |
| 201 | +```bash |
| 202 | +$ # Clone the source code: |
| 203 | +$ git clone https://github.com/app-generator/flask-material-kit.git |
| 204 | +$ cd flask-material-kit |
| 205 | +$ |
| 206 | +$ # Check Heroku CLI is installed |
| 207 | +$ heroku -v |
| 208 | +heroku/7.25.0 win32-x64 node-v12.13.0 # <-- All good |
| 209 | +$ |
| 210 | +$ # Check Heroku CLI is installed |
| 211 | +$ heroku login |
| 212 | +$ # this commaond will open a browser window - click the login button (in browser) |
| 213 | +$ |
| 214 | +$ # Create the Heroku project |
| 215 | +$ heroku create |
| 216 | +$ |
| 217 | +$ # Trigger the LIVE deploy |
| 218 | +$ git push heroku master |
| 219 | +$ |
| 220 | +$ # Open the LIVE app in browser |
| 221 | +$ heroku open |
| 222 | +``` |
| 223 | + |
| 224 | +<br /> |
| 225 | + |
| 226 | +### [Gunicorn](https://gunicorn.org/) |
| 227 | +--- |
| 228 | + |
| 229 | +Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. |
| 230 | + |
| 231 | +> Install using pip |
| 232 | +
|
| 233 | +```bash |
| 234 | +$ pip install gunicorn |
| 235 | +``` |
| 236 | +> Start the app using gunicorn binary |
| 237 | +
|
| 238 | +```bash |
| 239 | +$ gunicorn --bind 0.0.0.0:8001 run:app |
| 240 | +Serving on http://localhost:8001 |
| 241 | +``` |
| 242 | + |
| 243 | +Visit `http://localhost:8001` in your browser. The app should be up & running. |
| 244 | + |
| 245 | +<br /> |
| 246 | + |
| 247 | +### [Waitress](https://docs.pylonsproject.org/projects/waitress/en/stable/) |
| 248 | +--- |
| 249 | + |
| 250 | +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. |
| 251 | + |
| 252 | +> Install using pip |
| 253 | +
|
| 254 | +```bash |
| 255 | +$ pip install waitress |
| 256 | +``` |
| 257 | +> Start the app using [waitress-serve](https://docs.pylonsproject.org/projects/waitress/en/stable/runner.html) |
| 258 | +
|
| 259 | +```bash |
| 260 | +$ waitress-serve --port=8001 run:app |
| 261 | +Serving on http://localhost:8001 |
| 262 | +``` |
| 263 | + |
| 264 | +Visit `http://localhost:8001` in your browser. The app should be up & running. |
| 265 | + |
| 266 | +<br /> |
| 267 | + |
| 268 | +## ✨ Credits & Links |
| 269 | + |
| 270 | +- [Flask Framework](https://www.palletsprojects.com/p/flask/) - The official website |
| 271 | +- [Boilerplate Code](https://appseed.us/boilerplate-code) - Index provided by **AppSeed** |
| 272 | +- [Boilerplate Code](https://github.com/app-generator/boilerplate-code) - Index published on Github |
| 273 | + |
| 274 | +<br /> |
| 275 | + |
| 276 | +--- |
| 277 | +[Flask Material Kit](https://appseed.us/apps/flask-apps/flask-material-kit) - Provided by **AppSeed** [App Generator](https://appseed.us/app-generator). |
0 commit comments