Skip to content

Commit 10f33d1

Browse files
committed
Bump Codebase & UI
1 parent b988787 commit 10f33d1

File tree

373 files changed

+54071
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

373 files changed

+54071
-135
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
__pycache__
3+
*.pyc
4+
*.pyo
5+
*.pyd

.env

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# True for development, False for production
2+
DEBUG=False
3+
4+
# Flask ENV
5+
FLASK_APP=run.py
6+
FLASK_ENV=development
7+
8+
# If not provided, a random one is generated
9+
# SECRET_KEY=<YOUR_SUPER_KEY_HERE>
10+
11+
# Used for CDN (in production)
12+
# No Slash at the end
13+
ASSETS_ROOT=/static/assets
14+
15+
# If DB credentials (if NOT provided, or wrong values SQLite is used)
16+
# DB_ENGINE=mysql
17+
# DB_HOST=localhost
18+
# DB_NAME=appseed_db
19+
# DB_USERNAME=appseed_db_usr
20+
# DB_PASS=pass
21+
# DB_PORT=3306

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# tests and coverage
6+
*.pytest_cache
7+
.coverage
8+
9+
# database & logs
10+
*.db
11+
*.sqlite3
12+
*.log
13+
14+
# venv
15+
env
16+
venv
17+
18+
# other
19+
.DS_Store
20+
21+
# sphinx docs
22+
_build
23+
_static
24+
_templates
25+
26+
# javascript
27+
package-lock.json
28+
.vscode/symbols.json
29+
30+
apps/static/assets/node_modules
31+
apps/static/assets/yarn.lock
32+
apps/static/assets/.temp
33+

CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Change Log
2+
3+
## [1.0.5] 2023-07-12
4+
### Changes
5+
6+
- Deployment-ready for Render (CI/CD)
7+
- `render.yaml`
8+
- `build.sh`
9+
- `DB Management` Improvement
10+
- `Silent fallback` to **SQLite**
11+
12+
## [1.0.4] 2021-11-10
13+
### Changes
14+
15+
- Bump UI: Material Dashboard - v3.0.0
16+
- Update Bootstrap to v5.1.3
17+
- Update to Material Design 2
18+
- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v2.0.0
19+
- Dependencies update (all packages)
20+
- Flask==2.0.1 (latest stable version)
21+
- Better Code formatting
22+
- Improved Files organization
23+
- Optimize imports
24+
- Docker Scripts Update
25+
- Gulp Tooling (SASS Compilation)
26+
- Fixes:
27+
- Import error caused by WTForms
28+
29+
## [1.0.3] 2021-05-16
30+
### Changes
31+
32+
- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v1.0.6
33+
- Freeze used versions in `requirements.txt`
34+
- jinja2 = 2.11.3
35+
36+
## [1.0.2] 2021-05-11
37+
### Improvements
38+
39+
- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v1.0.5
40+
- Freeze used versions in `requirements.txt`
41+
- flask_sqlalchemy = 2.4.4
42+
- sqlalchemy = 1.3.23
43+
44+
## [1.0.1] 2021-02-10
45+
### Improvements
46+
47+
- Bump UI: [Jinja Material](https://github.com/app-generator/jinja-material-dashboard) v1.0.2
48+
- Bump Codebase: [Flask Dashboard](https://github.com/app-generator/boilerplate-code-flask-dashboard) v1.0.4
49+
50+
## [1.0.0] 2020-07-30
51+
### Initial Release

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.9
2+
3+
# set environment variables
4+
ENV PYTHONDONTWRITEBYTECODE 1
5+
ENV PYTHONUNBUFFERED 1
6+
7+
COPY requirements.txt .
8+
9+
# install python dependencies
10+
RUN pip install --upgrade pip
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
COPY . .
14+
15+
# gunicorn
16+
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "run:app"]

README.md

Lines changed: 15 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66

77
<br />
88

9-
> Free product - **Flask Dashboard** starter project - Features:
10-
11-
- Up-to-date [dependencies](./requirements.txt): **Flask 2.0.1**
12-
- [SCSS compilation](#recompile-css) via **Gulp**
13-
- UI Kit: **Material Dashboard - v3.0.0** (Bootstrap 5 Version) by **Creative-Tim**
14-
- Flask Codebase - provided by **[AppSeed](https://appseed.us/)**
15-
- SQLite, PostgreSQL, SQLAlchemy ORM
16-
- Alembic (DB schema migrations)
17-
- Modular design with **Blueprints**
18-
- Session-Based authentication (via **flask_login**)
19-
- Forms validation
20-
- Deployment scripts: Docker, Gunicorn / Nginx, Heroku
9+
> Features:
10+
11+
-`Up-to-date dependencies`
12+
- ✅ Database: `SQLite`
13+
-`DB Tools`: SQLAlchemy ORM, Flask-Migrate (schema migrations)
14+
- ✅ Session-Based authentication (via **flask_login**), Forms validation
15+
-`Docker`
16+
- ✅ CI/CD via `Render`
2117

2218
<br />
2319

@@ -47,28 +43,26 @@
4743

4844
## Docker Support
4945

50-
> Get the code
46+
> 👉 **Step 1** - Get the code
5147
5248
```bash
5349
$ git clone https://github.com/app-generator/material-dashboard-flask.git
5450
$ cd material-dashboard-flask
5551
```
5652

57-
> Start the app in Docker
53+
> 👉 **Step 2** - Start the APP in `Docker`
5854
5955
```bash
60-
$ docker-compose pull # download dependencies
61-
$ docker-compose build # local set up
62-
$ docker-compose up -d # start the app
56+
$ docker-compose up --build
6357
```
6458

65-
Visit `http://localhost:85` in your browser. The app should be up & running.
59+
Visit `http://localhost:5085` in your browser. The app should be up & running.
6660

6761
<br />
6862

69-
## Quick start
63+
## Manual Build
7064

71-
> UNZIP the sources or clone the private repository. After getting the code, open a terminal and navigate to the working directory, with product source code.
65+
> 👉 **Step 1** - Get the code
7266
7367
```bash
7468
$ # Get the code
@@ -112,122 +106,8 @@ $ # Access the dashboard in browser: http://127.0.0.1:5000/
112106
<br />
113107

114108
## Documentation
115-
The documentation for the **Material Dashboard Flask** is hosted at our [website](https://demos.creative-tim.com/material-dashboard-flask/docs/1.0/getting-started/getting-started-flask.html).
116-
117-
<br />
118-
119-
## File Structure
120-
Within the download you'll find the following directories and files:
121-
122-
```bash
123-
< PROJECT ROOT >
124-
|
125-
|-- apps/
126-
| |
127-
| |-- home/ # A simple app that serve HTML files
128-
| | |-- routes.py # Define app routes
129-
| |
130-
| |-- authentication/ # Handles auth routes (login and register)
131-
| | |-- routes.py # Define authentication routes
132-
| | |-- models.py # Defines models
133-
| | |-- forms.py # Define auth forms (login and register)
134-
| |
135-
| |-- static/
136-
| | |-- <css, JS, images> # CSS files, Javascripts files
137-
| |
138-
| |-- templates/ # Templates used to render pages
139-
| | |-- includes/ # HTML chunks and components
140-
| | | |-- navigation.html # Top menu component
141-
| | | |-- sidebar.html # Sidebar component
142-
| | | |-- footer.html # App Footer
143-
| | | |-- scripts.html # Scripts common to all pages
144-
| | |
145-
| | |-- layouts/ # Master pages
146-
| | | |-- base-fullscreen.html # Used by Authentication pages
147-
| | | |-- base.html # Used by common pages
148-
| | |
149-
| | |-- accounts/ # Authentication pages
150-
| | | |-- login.html # Login page
151-
| | | |-- register.html # Register page
152-
| | |
153-
| | |-- home/ # UI Kit Pages
154-
| | |-- index.html # Index page
155-
| | |-- 404-page.html # 404 page
156-
| | |-- *.html # All other pages
157-
| |
158-
| config.py # Set up the app
159-
| __init__.py # Initialize the app
160-
|
161-
|-- requirements.txt # Development modules - SQLite storage
162-
|-- requirements-mysql.txt # Production modules - Mysql DMBS
163-
|-- requirements-pqsql.txt # Production modules - PostgreSql DMBS
164-
|
165-
|-- Dockerfile # Deployment
166-
|-- docker-compose.yml # Deployment
167-
|-- gunicorn-cfg.py # Deployment
168-
|-- nginx # Deployment
169-
| |-- appseed-app.conf # Deployment
170-
|
171-
|-- .env # Inject Configuration via Environment
172-
|-- run.py # Start the app - WSGI gateway
173-
|
174-
|-- ************************************************************************
175-
```
176-
177-
<br />
178-
179-
> The bootstrap flow
180-
181-
- `run.py` loads the `.env` file
182-
- Initialize the app using the specified profile: *Debug* or *Production*
183-
- If env.DEBUG is set to *True* the SQLite storage is used
184-
- If env.DEBUG is set to *False* the specified DB driver is used (MySql, PostgreSQL)
185-
- Call the app factory method `create_app` defined in app/__init__.py
186-
- Redirect the guest users to Login page
187-
- Unlock the pages served by *home* blueprint for authenticated users
188-
189-
<br />
190-
191-
## Recompile CSS
192-
193-
To recompile SCSS files, follow this setup:
194-
195-
<br />
196-
197-
**Step #1** - Install tools
198-
199-
- [NodeJS](https://nodejs.org/en/) 12.x or higher
200-
- [Gulp](https://gulpjs.com/) - globally
201-
- `npm install -g gulp-cli`
202-
- [Yarn](https://yarnpkg.com/) (optional)
203109

204-
<br />
205-
206-
**Step #2** - Change the working directory to `assets` folder
207-
208-
```bash
209-
$ cd apps/static/assets
210-
```
211-
212-
<br />
213-
214-
**Step #3** - Install modules (this will create a classic `node_modules` directory)
215-
216-
```bash
217-
$ npm install
218-
// OR
219-
$ yarn
220-
```
221-
222-
<br />
223-
224-
**Step #4** - Edit & Recompile SCSS files
225-
226-
```bash
227-
$ gulp scss
228-
```
229-
230-
The generated file is saved in `static/assets/css` directory.
110+
The documentation for the **Material Dashboard Flask** is hosted at our [website](https://demos.creative-tim.com/material-dashboard-flask/docs/1.0/getting-started/getting-started-flask.html).
231111

232112
<br />
233113

apps/__init__.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from flask import Flask
7+
from flask_login import LoginManager
8+
from flask_sqlalchemy import SQLAlchemy
9+
from importlib import import_module
10+
11+
12+
db = SQLAlchemy()
13+
login_manager = LoginManager()
14+
15+
16+
def register_extensions(app):
17+
db.init_app(app)
18+
login_manager.init_app(app)
19+
20+
21+
def register_blueprints(app):
22+
for module_name in ('authentication', 'home'):
23+
module = import_module('apps.{}.routes'.format(module_name))
24+
app.register_blueprint(module.blueprint)
25+
26+
27+
def configure_database(app):
28+
29+
@app.before_first_request
30+
def initialize_database():
31+
try:
32+
db.create_all()
33+
except Exception as e:
34+
35+
print('> Error: DBMS Exception: ' + str(e) )
36+
37+
# fallback to SQLite
38+
basedir = os.path.abspath(os.path.dirname(__file__))
39+
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'db.sqlite3')
40+
41+
print('> Fallback to SQLite ')
42+
db.create_all()
43+
44+
@app.teardown_request
45+
def shutdown_session(exception=None):
46+
db.session.remove()
47+
48+
49+
def create_app(config):
50+
app = Flask(__name__)
51+
app.config.from_object(config)
52+
register_extensions(app)
53+
register_blueprints(app)
54+
configure_database(app)
55+
return app

apps/authentication/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from flask import Blueprint
7+
8+
blueprint = Blueprint(
9+
'authentication_blueprint',
10+
__name__,
11+
url_prefix=''
12+
)

0 commit comments

Comments
 (0)