Flask Datta Able ENH
Dashboard built by AppSeed in Flask on top of Datta Able design - Manual Coded Version.
This product is manualy coded on top of the generated version Datta Able PRO
Version: 1.0.13 - release date
2022-07-20
Bootstrap 5 Design,
Light/Dark Mode, 190 pages, Multiple LayoutsDB Tools: SQLAlchemy ORM,Flask-Migrate(schema migrations)Persistence: SQLite, MySqlAuthentication: Session Based, Social Login via Github & TwitterUsers ManagementExtended user profileComplete Users management (for
Admins)
APIvia Flask-RestXDeployment: Docker, Flask-Minify (page compression)
Links
👉 Datta Able Flask PRO - product page
✨ Environment
To use the starter, Python3 should be installed properly in the workstation. If you are not sure if Python is installed, please open a terminal and type python --version. Here is the full list with dependencies and tools required to build the app:
Python3 - the programming language used to code the app
GIT - used to clone the source code from the Github repository
Basic development tools (g++ compiler, python development libraries ..etc) used by Python to compile the app dependencies in your environment.
(Optional)
Docker- a popular virtualization software
✨ Start the app in Docker
👉 Step 1 - Access the product page and download the ZIP (requires a purchase)
👉 Step 2 - Start the APP in
Docker
Visit http://localhost:5085 in your browser. The app should be up & running
✨ Manual Build
Download the code - access the product page and download the ZIP (requires a purchase)
👉 Set Up for Unix, MacOS
Unix, MacOSInstall modules via
VENV
Set Up Flask Environment
Set Up Database
Create super admin (the superuser account)
Start the app
At this point, the app runs at http://127.0.0.1:5000/.
👉 Set Up for Windows
WindowsInstall modules via
VENV(windows)
Set Up Flask Environment
Set Up Database
Create super admin (the superuser account)
Start the app
At this point, the app runs at http://127.0.0.1:5000/.
APP Configuration via .env file
.env fileRename
env.sampleto.envand edit the variables:
Flask environment variables (used in development)
environment variables (used in development)FLASK_APP=run.py- run.py is the entry point in the projectFLASK_ENV=development
DEBUG Flag
DEBUG FlagDEBUG: ifTruethe SQLite persistence is used.For production use
False= this will switch to MySql persistence
ASSETS_ROOT used in assets management
ASSETS_ROOT used in assets managementdefault value:
/static/assets
FTP Settings
This section, once defined, the user is able to change their profile photo. To test the connection, run flask test_ftp.
FTP_SERVER- ftp server addressFTP_USER- ftp userFTP_PASSWORD- ftp passwordFTP_WWW_ROOT- the public address used for uploaded assets
MySql Credentials
This section is used when DEBUG is set to False (production mode)
DB_ENGINE, default value =mysqlDB_NAME, default value =appseed_dbDB_HOST, default value =localhostDB_PORT, default value =3306DB_USERNAME, default value =appseed_db_usrDB_PASS, default value =pass
Social Authentication via Github
GithubWhen credentials are defined, the app enables the LOGIN with Github button on Sign IN page.
GITHUB_ID=YOUR_GITHUB_IDGITHUB_SECRET=YOUR_GITHUB_SECRET
Social Authentication via Twitter
TwitterWhen credentials are defined, the app enables the LOGIN with Twitter button on Sign IN page.
TWITTER_ID=YOUR_GITHUB_IDTWITTER_SECRET=YOUR_GITHUB_SECRET
✨ Application Bootstrap Flow
The entry point of the project is the run.py file where the project configuration is bundled. The most important files that make the project functional are listed below:
run.pyis the application entry pointread the
Debugflag from.envimport the
dbobject fromappspackageimport the
create_apphelper fromapps
Flaskapplication is built bycreate_appIf
Debug=True- SQLite is used (development mode)If
Debug=False- SQLite is used (production mode)
Configuration
is defined in
apps/config.py
✨ API via Flask-RestX
Flask-RestXAPI stands for Application Programming Interface and it is used by various programs to communicate. When browsing the internet, you are using an API. The API takes your request, sends it to the service provider, fetches the response, and sends it back to you.
Flask-RestX Intro
Flask-RestX IntroFlask-RestX is an extension for Flask that allows us to build REST APIs faster. It has a collection of tools and decorators to help you describe and expose your API to the Swagger documentation.
The Swagger UI:
http://localhost:5000/api/
Exposed models
ProductsAPI
Definition:
apps/models/: Product ClassDefinition: id, name, information, description, price, currencyURI:
http://localhost:5000/api/products/
SalesAPI
Definition:
apps/models/: Sale ClassDefinition: id, product, state, value, fee, currency, client, payment_type, purchase_dateURI:
http://localhost:5000/api/products/
How to use the API
The API is secured via an api_token generated during the registration process. The value is saved in the Users table. Once the user is authenticated, the API_TOKEN is listed on the dashboard.
GET requests can be used without the API_TOKEN
All mutating requests (PUT, DELETE, POST) requires the presence of the API_TOKEN in the header:
Authorizationfield
Swagger UI
This visual tool is exposed at address
http://localhost:5000/api/and provides a fast access to the API
POSTMAN (3rd party tools)
Import the sample POSTMAN collection (saved on Github)
Replace the
Authorizationvalue with theAPI KEYlisted on your dashboardQuery the PRODUCTS API
create,updateanddeleteproducts
Query the SALES API
create,updateanddeletesales
\
✨ OAuth for Github and Twitter
Github and TwitterOpen Authorization (OAuth) is an authorization framework designed to allow third-party applications to access a user's data or resource. With this protocol, you can sign up and log in via social accounts like GitHub and Twitter.
Flask-Dance
Flask-DanceFlask-Dance is an extension that allows developers to create Flask-based applications with the option of authenticating via the OAuth protocol.
OAuth via Github
To authenticate via GitHub, we must define our credentials in the .env file.
GITHUB_ID=YOUR_GITHUB_IDGITHUB_SECRET=YOUR_GITHUB_SECRET
To get the credentials above;
Go to your GitHub account, navigate to
Settings->Developer Settings->OAuth AppsEdit the OAuth such that
Call back URL:
https://localhost:5000/login/github/authorizedHomepage URL:
https://localhost:5000
Once done, generate a secret key, and copy & paste it into the .env file. Do the same for the Client Id generated by GitHub.
Run the app using HTTPS

You can log in via the GitHub button.
OAuth via Twitter
To authenticate via Twitter, we must define our credentials in the .env file.
Sign IN to
TwitterGo to the
Developer SectionCreate a new APP
Edit settings
Check
OAuthversion: v1 or v2 (recommended)Callback URL:
https://localhost:5000/login/twitter/authorized
Edit the .env file and run the app using HTTPS
TWITTER_ID=YOUR_TWITTER_IDTWITTER_SECRET=YOUR_TWITTER_SECRET
You can log in via the Twitter button.
👉 Static Assets
The static assets used by the project (JS, 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
.envdefines theASSETS_ROOTvariableapps/config.pyread the value ofASSETS_ROOTand defaults to/static/assetsif not found:
All pages and components use the
config.ASSETS_ROOTvariable. Here is a sample extracted fromtemplates/layouts/base.html:
At runtime, the href property is resolved to /static/assets/css/style.css based on the value saved in the .env file:
🚀 Where to go from here
👉 Access the support page in case something is missing
👉 Use Datta Able Generator to generate a new project
Last updated
Was this helpful?