Skip to content

Commit 010e1c0

Browse files
committed
Import Codebase
1 parent b81eefd commit 010e1c0

File tree

144 files changed

+50388
-1
lines changed

Some content is hidden

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

144 files changed

+50388
-1
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# True for development, False for production
2+
DEBUG=True
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 DEBUG=False (production mode)
16+
# DB_ENGINE=mysql
17+
# DB_NAME=appseed_db
18+
# DB_HOST=localhost
19+
# DB_PORT=3306
20+
# DB_USERNAME=appseed_db_usr
21+
# DB_PASS=<STRONG_PASS>
22+
23+
# SOCIAL AUTH Github
24+
# GITHUB_ID=YOUR_GITHUB_ID
25+
# GITHUB_SECRET=YOUR_GITHUB_SECRET

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
34+
35+
migrations
36+

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.9
2+
3+
# set environment variables
4+
ENV PYTHONDONTWRITEBYTECODE 1
5+
ENV PYTHONUNBUFFERED 1
6+
ENV FLASK_APP run.py
7+
ENV DEBUG True
8+
9+
COPY requirements.txt .
10+
11+
# install python dependencies
12+
RUN pip install --upgrade pip
13+
RUN pip install --no-cache-dir -r requirements.txt
14+
15+
COPY env.sample .env
16+
17+
COPY . .
18+
19+
RUN flask db init
20+
RUN flask db migrate
21+
RUN flask db upgrade
22+
23+
# gunicorn
24+
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "run:app"]

LICENSE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MIT License
2+
3+
Copyright (c) 2019 - present [AppSeed](http://appseed.us/)
4+
5+
<br />
6+
7+
## Licensing Information
8+
9+
<br />
10+
11+
| Item | - |
12+
| ---------------------------------- | --- |
13+
| License Type | MIT |
14+
| Use for print | **YES** |
15+
| Create single personal website/app | **YES** |
16+
| Create single website/app for client | **YES** |
17+
| Create multiple website/apps for clients | **YES** |
18+
| Create multiple SaaS applications | **YES** |
19+
| End-product paying users | **YES** |
20+
| Product sale | **YES** |
21+
| Remove footer credits | **YES** |
22+
| --- | --- |
23+
| Remove copyright mentions from source code | NO |
24+
| Production deployment assistance | NO |
25+
| Create HTML/CSS template for sale | NO |
26+
| Create Theme/Template for CMS for sale | NO |
27+
| Separate sale of our UI Elements | NO |
28+
29+
<br />
30+
31+
---
32+
For more information regarding licensing, please contact the AppSeed Service < *support@appseed.us* >

README.md

Lines changed: 209 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,209 @@
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+
![Datta Able (enhaced with dark mode) - Open-Source Seed project generated by AppSeed.](https://user-images.githubusercontent.com/51070104/176118649-7233ffbc-6118-4f56-8cda-baa81d256877.png)
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/)**.

apps/__init__.py

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

0 commit comments

Comments
 (0)