Skip to content

Commit

Permalink
Make thumbtack command serve the CWD
Browse files Browse the repository at this point in the history
  • Loading branch information
jondricek committed Apr 9, 2019
1 parent a1fbf09 commit 1241504
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'Flask-RESTful',
'gunicorn',
'imagemounter',
'requests',
'pathlib2 ; python_version<"3.4"',
]

Expand Down
26 changes: 14 additions & 12 deletions thumbtack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
__version__ = 'Could not find version'


def create_app():
def create_app(image_dir=None):
app = Flask(__name__)
app.config.from_object('thumbtack.config')
# Since development doesn't have this environment variable, it won't do anything
app.config.from_envvar('THUMBTACK_CONFIG_PRODUCTION', silent=True)

IMAGE_DIR = os.environ.get("IMAGE_DIR", default=None)
MOUNT_DIR = os.environ.get("MOUNT_DIR", default=None)
IMAGE_DIR = os.environ.get("IMAGE_DIR")
MOUNT_DIR = os.environ.get("MOUNT_DIR")

if IMAGE_DIR is not None:
app.config.update(
IMAGE_DIR=IMAGE_DIR,
)
if MOUNT_DIR is not None:
app.config.update(
MOUNT_DIR=MOUNT_DIR,
)
if IMAGE_DIR:
app.config.update(IMAGE_DIR=IMAGE_DIR)

# image_dir is used in the thumbtack entry point, and overwrites the environment variable
if image_dir:
app.config.update(IMAGE_DIR=image_dir)

if MOUNT_DIR:
app.config.update(MOUNT_DIR=MOUNT_DIR)

configure(app)

Expand Down Expand Up @@ -83,5 +84,6 @@ def configure_logging(app):


def start_app():
app = create_app()
image_dir = os.getcwd()
app = create_app(image_dir=image_dir)
app.run(debug=True)

0 comments on commit 1241504

Please sign in to comment.