This document provides instructions for working with Flask and the CommandK CLI. It explains how to run your Flask application and manage secrets effectively using the CommandK CLI.


Before you begin the integration process, make sure you have the following:

  1. API Access Token: To authenticate your Flask application with CommandK, you'll need an API access token. If you haven't obtained one yet, refer to this link for instructions on how to acquire it.

Integration Steps

Follow these steps to integrate CommandK with your Flask application:

Step 1: Create a Flask Application

If you haven't already created a Flask application, you can set up a new project using a preferred method. Here, we'll create a simple Flask application for demonstration:

  1. Create a directory for your Flask application:

    mkdir my_flask_app
    cd my_flask_app
  2. Install Flask:

    pip install Flask	
  3. Create a Python file for your Flask application, e.g., app.py, and add a basic Flask app:

    from flask import Flask
    app = Flask(__name__)
    def hello_world():
        return 'Hello, Flask!'
    if __name__ == '__main__':

Step 2: Access Secrets in Your Flask Application

Inside your Flask application, you can access secrets as environment variables. Open the appropriate file (e.g., app.py) and add the following code snippet to access an environment variable:

import os
from dotenv import load_dotenv



This code uses the dotenv library to load environment variables and sets the Flask secret key as an example.

Running Your Flask Application

To run your Flask application with the CommandK CLI, you can use the following command:

$ cmdk run <application-name> --environment development -- python app.py

Replace <application-name> with the actual name of your Flask application. This command will execute your Flask application, running it with the Python interpreter.

By following these instructions, you can seamlessly integrate the CommandK CLI with your Flask application, making it easy to manage secrets and run your application securely.