Setting Up Your Dev Environment

This section is meant to help you set up an environment like the one in this lab. Obviously it helps to have access to lab equipment, such as a CUCM, Unity Connection, or other servers and devices that you can use to test against.

Since you probably are familiar with setting that part of the infrastructure up, we will focus on the development side of things. These instructions will diverge slightly, depending on the machine and operating system you intend to use for development (e.g. Mac, Windows, Linux). But in general, here are some tips to get up and running:

Step 1 - Your Development Environment

To get started, you need to make sure your machine is set up properly for Python development.

  1. Start by loading Microsoft Visual Studio Code. There are other editors/IDEs (the free, community-edition Pycharm may be better overall, but it does tend to have a heavier footprint in terms of how much resources it uses). For Windows deployments, follow the VS Code instructions for installing subsequent software.

    For a nice overview, check out this article on RealPython.com

  2. Be sure to install at a minimum the Python Extension in Visual Studio Code
  3. Install Python3. This will give you Python and Pip, the Python package installer needed to load other things.
  4. Familiarize yourself with Virtual Environments and use them.

Step 2 - Clone the Lab Repository

Once your development machine is up and running, time to clone our repo.

  1. Clone our repo: git clone https://github.com/collabapilab/ltrcol-2574-portal.git
  2. This repo contains two branches:
    • master: This branch (default) contains the fully built-out Portal
    • skeleton: This branch contains a partially built-out Portal that is meant to be used while following this lab guide. https://collabapilab.ciscolive.com
  3. Set up a virtual environment for this project.
  4. Install required Python packages with pip. E.g. from the folder created when you cloned the repo: pip install -r requirements.txt
  5. Launch VS Code

Step 3 - Run the Flask App

Now you're at the point where a few customizations may be required and then you can run the app.

  1. By default, the app will run on port 5000. If this is not desireable, then one way you can change it is by setting an environment variable: export FLASK_RUN_PORT=5555
  2. The simple way to just run the server in development mode (not debug mode!) is from a command line: python -m flask run
  3. One of the ways to start the server with a debugger attached, in VS Code, is by using a launch.json file. For example, in our lab, you see a Start LTRCOL-2574 Portal button from the Debug menu configurations. In all VS Code installations, you can add/change the parameters of this file. In our instance we have the following in our launch.json:
    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python: hello_world.py",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/examples/hello_world.py",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Python: soap_axl.py",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/examples/soap_axl.py",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Python: soap_sxml.py",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/examples/soap_sxml.py",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Python: wxc_enable_user.py",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/examples/wxc_enable_user.py",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Python: service_app.py",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/examples/service_app.py",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Python: wbx_messages.py",
                "type": "python",
                "request": "launch",
                "program": "${workspaceFolder}/examples/wbx_messages.py",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Start LTRCOL-2574 Portal",
                "type": "python",
                "request": "launch",
                "module": "flask",
                // https://flask.palletsprojects.com/en/1.1.x/config/#configuring-from-environment-variables
                "env": {
                    "FLASK_APP": "app.py",
                    "FLASK_ENV": "development",
                    "FLASK_DEBUG": "0"
                },
                "args": [
                    "run",
                    "--host=0.0.0.0",
                    "--no-debugger",
                    "--no-reload"
                ],
                "jinja": true
            }
        ]
    }