Creative-Tim
.DB Tools
: SQLAlchemy ORM, Flask-Migrate (schema migrations)Links
python --version
. Here is the full list with dependencies and tools required to build the app:Docker
- a popular virtualization softwareπ Step 1 - Download the code from the GH repository (usingGIT
)
π Step 2 - Start the APP inDocker
http://localhost:5085
in your browser. The app should be up & running.Download the code
Unix
, MacOS
Install modules viaVENV
Set Up Flask Environment
Start the app
http://127.0.0.1:5000/
.Windows
Install modules viaVENV
(windows)
Set Up Flask Environment
Start the app
http://127.0.0.1:5000/
.Users
flask run
registration
page and create a new user:http://127.0.0.1:5000/register
sign in
page and authenticatehttp://127.0.0.1:5000/login
run.py
file where the project configuration is bundled. The most important files
that make the project functional are listed below:run.py
is the application entry pointDebug
flag from .env
db
object from apps
packagecreate_app
helper from apps
Flask
application is built by create_app
Debug=True
- SQLite is used (development mode)Debug=False
- SQLite is used (production mode)apps/config.py
Flask App
object is constructedapps/__init__.py
. The most important steps are listed below:db
object.SQLAlchemy
we can manage the database information with easelogin_manager
object.login_manager
manage the authentication layer (login, logout, register)create_app
helper that does the following:Flask
app objectdb
and login_manager
objectsconfiguration
default blueprints
:authentication
- handles the authentication routeshome
- serve all the pages saved in the apps/templates/home
folderdb.create_all()
- create all tablesblueprints
. By default, the project comes with a two blueprints
Definition:apps/authentication
. The core files:
__init__.py
- defines the Blueprint objectmodels.py
- defines the Users
modelforms.py
- defines the Login
and Registration
formsutils.py
- helpers used to hass and verify the passwordroutes
- manages the authentication routes:login
register
logout
templates/home
directory to authenticated users. In case a page is not found, a generic page is returned using a 404
HTTP error status.apps/templates
directory. Here are the standard directories:templates/layouts
: UI masterpagestemplates/includes
: UI components (used across multiple pages)templates/accounts
: login & registration pagetemplates/home
: all other pages served via a generic routing by apps/home
appJS
, CSS
, images
) are saved inside the apps/static/assets
folder. This path can be customized with ease via ASSETS_ROOT
variable saved in the .env
file.How it works
.env
defines the ASSETS_ROOT
variableapps/config.py
read the value of ASSETS_ROOT
and defaults to /static/assets
if not found:config.ASSETS_ROOT
variable. Here is a sample extracted from templates/layouts/base.html
:href
property is resolved to /static/assets/css/style.css
based on the value saved in the .env
file:Step 1 - Create the MySql Database to be used by the app
Create a new MySql
databaseCreate a new user
and assign full privilegies (read/write)Step 2 - Installflask_mysqldb
package
Step 3 - Edit the.env
to match your MySql DB credentials. Make sureDEBUG
is set toFalse
.
DB_ENGINE
: mysql
DB_NAME
: default value = appseed_db
DB_HOST
: default value = localhost
DB_PORT
: default value = 3306
DB_USERNAME
: default value = appseed_db_usr
DB_PASS
: default value = pass
MySql
for the persistence layer.production
apps/static/assets
- the folder where JS
, CSS
, and images
files are savedASSETS_ROOT
- environment variable, that defaults to /static/assets
if not definedapps/static/assets
files should be copied to an external (public) directory and the ASSETS_ROOT
environment variable updated accordingly.static
files are copied to https://cdn.your-server.com/datta-able-assets
, the .env
file should be updated as below:live demo
) for more features and improved UIBootstrap 5
version