|
| 1 | +# **Flask WebMF** |
| 2 | + |
| 3 | +## **Using on Mac OS X Host** |
| 4 | + |
| 5 | +* Prerequisites: |
| 6 | + * Install XCode Command Line Tools |
| 7 | + * Install Brew `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` |
| 8 | + |
| 9 | +### **Install** |
| 10 | + |
| 11 | +```bash |
| 12 | +$ brew install python |
| 13 | +$ # Install/Setup virtualenv (optional) |
| 14 | +$ pip install virtualenv |
| 15 | +$ pip install virtualenvwrapper |
| 16 | +$ mkdir ${HOME}/.virtualenvs |
| 17 | +$ source /usr/local/bin/virtualenvwrapper.sh |
| 18 | +``` |
| 19 | + |
| 20 | +## **Run** |
| 21 | + |
| 22 | +```bash |
| 23 | +$ pip install flask # install flask library |
| 24 | +$ ./app.py # run program |
| 25 | +``` |
| 26 | + |
| 27 | +### **Run Using Virtualenv** |
| 28 | + |
| 29 | +This uses [virtualenv](https://virtualenv.pypa.io/en/latest/), so that libraries are installed in locally in only your account. |
| 30 | + |
| 31 | +```bash |
| 32 | +$ mkvirtualenv flaskenv # create segregated environment |
| 33 | +$ pip install -r requirements.txt # install flask library locally |
| 34 | +$ ./app.py # run program |
| 35 | +$ ## Run Tests Here (see below) |
| 36 | +$ deactivate # exit segregated environment |
| 37 | +``` |
| 38 | + |
| 39 | +## **Using Docker or Vagrant** |
| 40 | + |
| 41 | +See [Tools Readme](../TOOLS.md) for more information on install, setup, and start Docker or Vagrant. |
| 42 | + |
| 43 | +### **Build and Run with Docker Compose** |
| 44 | + |
| 45 | +```bash |
| 46 | +$ docker-compose up -d |
| 47 | +``` |
| 48 | + |
| 49 | +### **Build and Run with Vagrant** |
| 50 | + |
| 51 | +```bash |
| 52 | +$ vagrant up |
| 53 | +``` |
| 54 | + |
| 55 | +## **Testing Results** |
| 56 | + |
| 57 | +```bash |
| 58 | +$ [ -z ${DOCKER_MACHINE_NAME} ] || WEBSERVER=$(docker-machine ip ${DOCKER_MACHINE_NAME}) |
| 59 | +$ WEBSERVER=${WEBSERVER:-localhost} |
| 60 | +$ PORT=5000 |
| 61 | +$ curl -i ${WEBSERVER}:${PORT} |
| 62 | +HTTP/1.0 200 OK |
| 63 | +Content-Type: text/html; charset=utf-8 |
| 64 | +Content-Length: 13 |
| 65 | +Server: Werkzeug/0.11.4 Python/2.7.11 |
| 66 | +Date: Sun, 13 Mar 2016 07:02:41 GMT |
| 67 | + |
| 68 | +Hello World! |
| 69 | +``` |
0 commit comments