Skip to main content

Environment Variables

Environment Variables are powerful tools in programming that allow for the storage and use of important system information. These variables are used to store information such as paths, settings, and configurations related to the operating system.

Importance of Environment Variables

  1. Flexibility: They allow for changing application settings without the need to modify the code.
  2. Security: They are used to store sensitive information, such as API keys, without directly embedding them in the application code.
  3. Compatibility Across Environments: They enable the application to run in different environments with varying settings.

How to Define Environment Variables?

Kubar provides the ability to define and use Environment Variables during project creation and execution. To define environment variables:

During Project Creation
  1. On the Advanced Settings page, click on the Environment Variables tab.
  2. Click on the Add Variable option.
  3. Enter the name and value of the environment variable.

Create App

During Project Execution
  1. Go to the Environment Variables tab in the Kubar panel.
  2. Click on the Add Variable option.
  3. Enter the name and value of the environment variable.
  4. Click on Apply Changes.

Run Project

How to Use Environment Variables in Your Applications?

In Python, you can access environment variables using the os module:

import os

database_url = os.environ.get('DATABASE_URL')
caution
  • Use environment variables to store sensitive information such as API keys, passwords, and database addresses.
  • Avoid placing files containing your environment variables in version control systems (like Git).

By properly utilizing environment variables, you can enhance the security, flexibility, and maintainability of your applications.