---
# System prepended metadata

title: 'Steps that I did:'

---

# Steps that I did:

1. Create initial environment and directory structure

```bash
mkdir flask-app-vbox
cd flask-app-vbox

# Make a directory to house our Flask app later
mkdir data

# Create a directory for Vagrant config
mkdir vm 
cd vm
vagrant init ubuntu/xenial64 
```

3. Update Vagrantfile config:

```sh
# From flask-app-vbox/vm, run:
vim Vagrantfile
# Update the forwarded port config to 5000, since that’s what Flask uses, letting us develop on localhost
config.vm.network "forwarded_port", guest: 5000, host: 5000

# Uncomment the line that starts with “config.vm.synced_folder” 
# so that files on the host computer are synced with files on
# the VM. We'll just use Vagrant's default config for this instead of changing the names for the folders.


```

4. Create the VM itself, and ssh in.
```sh
# From `flask-app-vbox/vm`, run:
vagrant up
vagrant ssh
```

## Okay, now we’re in the VM...

### Approach
1. First, CREATE a new flask project inside the VM.
2. Install Datadog’s ddtrace module to it.

---

Previously, in step 2, we created a “data” folder on the host machine, at`flask-app-vbox/data`. Then, in step 3, we synced that `data` folder to an equivalent location on the VM, at `/vagrant_data`. So in the VM, let’s go there. It should be an empty directory right now.

```
cd /vagrant_data
```

Here, we can create our Flask app, but let's first create the virtualenv.

```shell=bash
# Install the tools necessary to create the virtualenv
sudo apt-get install python3-venv

# Make a directory .venv that will house the virtualenv stuff
python3 -m venv .venv

# Activate the virtualenv
source .venv/bin/activate # The prompt should change to indicate the env is active.

# Install Flask
pip install Flask

# We can create a HelloWorld app named hello.py as per Flask docs: https://flask.palletsprojects.com/en/1.1.x/quickstart/

# Run the app
export FLASK_APP=hello.py
flask run

# If you see: `Serving Flask app "hello.py"` without an errors - it's a success!

# Before exiting, let's freeze requirements using Pip, much like Node's package.json:

> python3 -m pip freeze > requirements.txt
```

2. Install Datadog's `ddtrace` module:

- Run their one-liner:
    - `DD_API_KEY=43a45bc412e799011ad10c5d6154acfe DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"`



