Skip to content

Commit 541030d

Browse files
committed
Import Codebase
1 parent 4dc5e29 commit 541030d

File tree

350 files changed

+58400
-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.

350 files changed

+58400
-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: 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+

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"]

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: 194 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,194 @@
1-
# boilerplate-code-flask
1+
# [Flask Boilerplate](https://appseed.us/boilerplate-code/flask-boilerplate/)
2+
3+
Reference codebase used by `AppSeed` in all Flask [Apps](https://appseed.us/apps/flask/) and [Dashboard](https://appseed.us/admin-dashboards/flask/) starters - the product uses an amazing design crafted by Creative-Tim.
4+
5+
- 👉 [Flask Boilerplate](https://appseed.us/boilerplate-code/flask-boilerplate/) - `Product page`
6+
- 👉 [Flask Boilerplate](https://flask-material-kit.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-08 12:24`
12+
13+
-`Up-to-date dependencies`
14+
-`Database`: `SQLite`, MySql
15+
- Silent fallback to `SQLite`
16+
-`DB Tools`: SQLAlchemy ORM, Flask-Migrate (schema migrations)
17+
- ✅ Session-Based authentication (via **flask_login**), Forms validation
18+
- ✅ Docker, `Flask-Minify` (page compression)
19+
- 🚀 `Deployment`
20+
- `CI/CD` flow via `Render`
21+
- [Flask Material Kit - Go LIVE](https://www.youtube.com/watch?v=bSFw6xrd57w) (`video presentation`)
22+
23+
<br />
24+
25+
![Material Kit - Starter generated by AppSeed.](https://user-images.githubusercontent.com/51070104/167396765-c88b7a95-155f-4236-8691-7b80fa2d9cd9.png)
26+
27+
<br />
28+
29+
## Start with `Docker`
30+
31+
> 👉 **Step 1** - Download the code from the GH repository (using `GIT`)
32+
33+
```bash
34+
$ git clone https://github.com/app-generator/boilerplate-code-flask.git
35+
$ cd boilerplate-code-flask
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+
## Manual Build
51+
52+
> Download the code
53+
54+
```bash
55+
$ git clone https://github.com/app-generator/boilerplate-code-flask.git
56+
$ cd boilerplate-code-flask
57+
```
58+
59+
<br />
60+
61+
### 👉 Set Up for `Unix`, `MacOS`
62+
63+
> Install modules via `VENV`
64+
65+
```bash
66+
$ virtualenv env
67+
$ source env/bin/activate
68+
$ pip3 install -r requirements.txt
69+
```
70+
71+
<br />
72+
73+
> Set Up Flask Environment
74+
75+
```bash
76+
$ export FLASK_APP=run.py
77+
$ export FLASK_ENV=development
78+
```
79+
80+
<br />
81+
82+
> Start the app
83+
84+
```bash
85+
$ flask run
86+
```
87+
88+
At this point, the app runs at `http://127.0.0.1:5000/`.
89+
90+
<br />
91+
92+
### 👉 Set Up for `Windows`
93+
94+
> Install modules via `VENV` (windows)
95+
96+
```
97+
$ virtualenv env
98+
$ .\env\Scripts\activate
99+
$ pip3 install -r requirements.txt
100+
```
101+
102+
<br />
103+
104+
> Set Up Flask Environment
105+
106+
```bash
107+
$ # CMD
108+
$ set FLASK_APP=run.py
109+
$ set FLASK_ENV=development
110+
$
111+
$ # Powershell
112+
$ $env:FLASK_APP = ".\run.py"
113+
$ $env:FLASK_ENV = "development"
114+
```
115+
116+
<br />
117+
118+
> Start the app
119+
120+
```bash
121+
$ flask run
122+
```
123+
124+
At this point, the app runs at `http://127.0.0.1:5000/`.
125+
126+
<br />
127+
128+
### 👉 Create Users
129+
130+
By default, the app redirects guest users to authenticate. In order to access the private pages, follow this set up:
131+
132+
- Start the app via `flask run`
133+
- Access the `registration` page and create a new user:
134+
- `http://127.0.0.1:5000/register`
135+
- Access the `sign in` page and authenticate
136+
- `http://127.0.0.1:5000/login`
137+
138+
<br />
139+
140+
## Codebase Structure
141+
142+
The project is coded using blueprints, app factory pattern, dual configuration profile (development and production) and an intuitive structure presented bellow:
143+
144+
```bash
145+
< PROJECT ROOT >
146+
|
147+
|-- apps/
148+
| |
149+
| |-- home/ # A simple app that serve HTML files
150+
| | |-- routes.py # Define app routes
151+
| |
152+
| |-- authentication/ # Handles auth routes (login and register)
153+
| | |-- routes.py # Define authentication routes
154+
| | |-- models.py # Defines models
155+
| | |-- forms.py # Define auth forms (login and register)
156+
| |
157+
| |-- static/
158+
| | |-- <css, JS, images> # CSS files, Javascripts files
159+
| |
160+
| |-- templates/ # Templates used to render pages
161+
| | |-- includes/ # HTML chunks and components
162+
| | | |-- navigation.html # Top menu component
163+
| | | |-- sidebar.html # Sidebar component
164+
| | | |-- footer.html # App Footer
165+
| | | |-- scripts.html # Scripts common to all pages
166+
| | |
167+
| | |-- layouts/ # Master pages
168+
| | | |-- base-fullscreen.html # Used by Authentication pages
169+
| | | |-- base.html # Used by common pages
170+
| | |
171+
| | |-- accounts/ # Authentication pages
172+
| | | |-- login.html # Login page
173+
| | | |-- register.html # Register page
174+
| | |
175+
| | |-- home/ # UI Kit Pages
176+
| | |-- index.html # Index page
177+
| | |-- 404-page.html # 404 page
178+
| | |-- *.html # All other pages
179+
| |
180+
| config.py # Set up the app
181+
| __init__.py # Initialize the app
182+
|
183+
|-- requirements.txt # App Dependencies
184+
|
185+
|-- .env # Inject Configuration via Environment
186+
|-- run.py # Start the app - WSGI gateway
187+
|
188+
|-- ************************************************************************
189+
```
190+
191+
<br />
192+
193+
---
194+
[Flask Boilerplate](https://appseed.us/boilerplate-code/flask-boilerplate/) - Open-source starter generated by **[App Generator](https://appseed.us/generator/)**.

apps/__init__.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
51+
def create_app(config):
52+
app = Flask(__name__)
53+
app.config.from_object(config)
54+
register_extensions(app)
55+
register_blueprints(app)
56+
configure_database(app)
57+
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)