Skip to content

Commit 6992b40

Browse files
committed
Added flask env variables, made python path less specific, avoided 'name resolution' error in run.py
1 parent fc3cf3e commit 6992b40

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# About This Application
22

33
To build this application you must...
4-
1. Run the setup file with the command
4+
1. Have python 2.7 and `virtualenv` installed
5+
2. Run the setup file with the command
56
source setup.sh
6-
2. Populate the database with generic values
7+
3. Populate the database with generic values
78
python reset-db.py
8-
3. Add your current machine user id to admin in config/role.yaml
9-
4. Start Appache server to serve application
9+
4. Add your current machine user id to admin in config/roles.yaml
10+
5. Start webserver to serve application
1011
python run.py
11-
5. Open 0.0.0.0:8000 in your browser
12+
6. Open 0.0.0.0:8080 in your browser
1213

1314
# Relevant Documentation
1415

config/roles.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ admin:
44
- hooverk
55
- insengrim
66
- ramsayb2
7+
- heggens
78
# - database Roles
89

910
systemAdmin:

run.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
import os
77

88
# Builds the server configuration
9+
IP = '0.0.0.0'
910
if os.getenv('USER'):
1011
hostname = os.getenv('USER')
11-
IP = socket.gethostbyname(hostname)
12-
else:
13-
IP = '0.0.0.0'
12+
try:
13+
IP = socket.gethostbyname(hostname)
14+
except:
15+
pass
1416

1517
# Run the web application.
1618
app.run(debug = config.sys.debug, host = IP, port = config.sys.port)

setup.sh

100644100755
+7-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# exporting these variables into the shell environment before
55
# sourcing this script. If these variables exist before this
66
# script is sourced, then the pre-existing values will be used.
7-
WERKZEUG_VERSION="${WERKZEUG_VERSION:-0.16.0}"
87
FLASK_VERSION="${FLASK_VERSION:-0.12.1}"
8+
WERKZEUG_VERSION="${WERKZEUG_VERSION:-0.16.0}"
99
WTFORMS_VERSION="${WTFORMS_VERSION:-2.1}"
1010
FLASK_SESSION_VERSION="${FLASK_SESSION_VERSION:-0.2.3}"
1111
FLASK_ADMIN_VERSION="${FLASK_ADMIN_VERSION:-1.4.0}"
@@ -47,7 +47,7 @@ else
4747
fi
4848

4949
# Create and activate a clean virtual environment.
50-
virtualenv --python=/usr/bin/python2.7 venv
50+
virtualenv --python=python2.7 venv
5151
. venv/bin/activate
5252

5353
# Create a data directory
@@ -91,3 +91,8 @@ pip install "openpyxl==$OPENPYXL_VERSION" #2.4.5
9191

9292
pip install "unidecode==$UNIDECODE_VERSION" #0.4.20
9393
# https://pypi.python.org/pypi/Unidecode
94+
95+
export FLASK_APP=run.py
96+
export FLASK_ENV=development
97+
export FLASK_RUN_PORT=8080
98+
export FLASK_RUN_HOST=0.0.0.0 # To allow external routing to the application for development

0 commit comments

Comments
 (0)