Getting Started

This document is aimed to create and run your Metronic based Flask project in just 5 minutes. It's assumed that you already purchased Metronic  and downloaded from Metronic Downloads.

Pre Requirements

We recommend using the latest version of Python. Flask supports Python 3.7 and newer. Here's required technology and languages to get started:
Assets compile require the build tools. These libraries are required as below:

HTML Features

The Starter Kit includes only the theme source code(sass, js, media, fonts and icons) from the HTML version, build tools(Gulp, Webpack), layout views and general pages(index, authentication, error) integration.
To use any feature shown in the HTML version just copy & paste the HTML code and include required assets(css, js) using the Theme Api.

Install Python

Flask is a Python web framework.

  1. Get the latest version of Python at https://www.python.org/downloads/  or with your operating system’s package manager.
  2. Download the executable installer and run it.
  3. Check the boxes next to “Install launcher for all users (recommended)” then click “Install Now”.
  4. After installation, open the command prompt and check that the Python version matches the version you installed by executing:
    python --version

Install Flask

Flask can be installed easily using pip. Within the activated environment, use the following command to install Flask:

  1. Before you work on your project, activate the corresponding environment. In the command prompt within the project folder starterkit.

    For macOS/Linux:
    . venv/Scripts/activate
    For Windows:
    venv\Scripts\activate
    Your shell prompt will change to show the name of the activated environment.
  2. In the command prompt and execute the following command:
    pip install Flask
    Flask is now installed.

Build assets

Before running the application we need to build theme assets:
  1. Start a command prompt window or terminal and change directory to starterkit/_keenthemes/tools
    cd starterkit/_keenthemes/tools
  2. Install dependencies with either one, yarn or npm:
    yarn install
    You can use either one.
    npm install
    This command will fetch all dependencies listed in starterkit/_keenthemes/tools/package.json and place them into _keenthemes/tools/node_modules folder.
  3. You can use Gulp  or Webpack  commands to bundle theme assets. The below command will compile all the assets(sass, js, media) to starterkit/assets folder:
    For gulp use command:
    gulp
    For webpack use command:
    npm run build
    Note on the package.json file. This step is very important for Webpack in Metronic template. The default package.json works for Gulp. To make it work for Webpack, you have to modify tools/package.json and remove "type": "module". Otherwise, it will cause compilation error when running the build command.

Run Flask

To run the Flask application navigate your prompt to starterkit folder and run the following command.
  1. Navigate your prompt to starterkit folder.
    cd starterkit
  2. For macOS/Linux only, this step is required. Navigate to the directory where the run.sh script is located using the cd command. Make the script executable using the chmod command:
    chmod +x run.sh
  3. For macOS/Linux, run the script by typing its name and pressing Enter:
    ./run.sh
    For Windows:
    run.bat
    For debug mode, use --debug flag. Eg. ./run.sh --debug
  4. By default application is served on http://127.0.0.1:5000/.
  5. In essence, this script automates the setup of a Python virtual environment, installation of package dependencies, and the execution of a Flask web application. It's designed to be cross-platform, accommodating both macOS/Linux and Windows systems. The use of the virtual environment helps manage package dependencies independently of the system-wide Python installation. The script also allows for running the Flask app in debug mode if specified.
Preview Get Help Buy Now