From efab60744e7284e245bbd6266755ab3ca1a37200 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Sat, 31 Oct 2020 12:05:31 -0400 Subject: Rename demo to poller --- .travis.yml | 4 ++-- Dockerfile | 10 +++++----- README.md | 4 ++-- config.env.py | 2 +- demo/__init__.py | 20 -------------------- poller/__init__.py | 20 ++++++++++++++++++++ requirements.txt | 1 + wsgi.py | 2 +- 8 files changed, 32 insertions(+), 31 deletions(-) delete mode 100644 demo/__init__.py create mode 100644 poller/__init__.py diff --git a/.travis.yml b/.travis.yml index 7e891f8..9935a5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,6 @@ services: install: - "pip install -r requirements.txt" script: - - "pylint demo" - - "docker build -t demo ." + - "pylint poller" + - "docker build -t poller ." diff --git a/Dockerfile b/Dockerfile index 194a42a..570c4ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ FROM python:3.8-alpine MAINTAINER Galen Guyer -RUN mkdir /opt/demo +RUN mkdir /app -ADD requirements.txt /opt/demo +ADD requirements.txt /app -WORKDIR /opt/demo +WORKDIR /app RUN pip install -r requirements.txt -ADD . /opt/demo +ADD . /app RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime -CMD ["gunicorn", "demo:APP", "--bind=0.0.0.0:8080", "--access-logfile=-"] +CMD ["gunicorn", "poller:APP", "--bind=0.0.0.0:8080", "--access-logfile=-"] diff --git a/README.md b/README.md index 7919b4f..445bf35 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ Locally running this application should be pretty simple. 2. Install dependencies * `pip install -r requirements.txt` 3. Run the app - * `gunicorn demo:APP --bind=localhost:5000` + * `gunicorn poller:APP --bind=localhost:5000` 4. Visit localhost:5000 in your web browser. ## Linting This demo uses pylint. -Travis CI will automatically run pylint on commits and PRs, but you can also run pylint manually, using `pylint demo`. +Travis CI will automatically run pylint on commits and PRs, but you can also run pylint manually, using `pylint poller`. The pylint_quotes plugin is loaded by [the pylintrc](./.pylintrc) and will ensure standardised quotation mark formats. diff --git a/config.env.py b/config.env.py index e996ffa..fd7c9ac 100644 --- a/config.env.py +++ b/config.env.py @@ -12,6 +12,6 @@ import os # Defaults for flask configuration IP = os.environ.get('IP', '127.0.0.1') PORT = os.environ.get('PORT', 5000) -SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost:5000') +#SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost:5000') SECRET_KEY = os.environ.get('SESSION_KEY', default=''.join(secrets.token_hex(16))) diff --git a/demo/__init__.py b/demo/__init__.py deleted file mode 100644 index 86af046..0000000 --- a/demo/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -""" A small flask Hello World """ - -import os -import subprocess - -from flask import Flask, jsonify - -APP = Flask(__name__) - -# Load file based configuration overrides if present -if os.path.exists(os.path.join(os.getcwd(), 'config.py')): - APP.config.from_pyfile(os.path.join(os.getcwd(), 'config.py')) -else: - APP.config.from_pyfile(os.path.join(os.getcwd(), 'config.env.py')) - -APP.secret_key = APP.config['SECRET_KEY'] - -@APP.route('/') -def _index(): - return jsonify(status=200, response="OK") diff --git a/poller/__init__.py b/poller/__init__.py new file mode 100644 index 0000000..86af046 --- /dev/null +++ b/poller/__init__.py @@ -0,0 +1,20 @@ +""" A small flask Hello World """ + +import os +import subprocess + +from flask import Flask, jsonify + +APP = Flask(__name__) + +# Load file based configuration overrides if present +if os.path.exists(os.path.join(os.getcwd(), 'config.py')): + APP.config.from_pyfile(os.path.join(os.getcwd(), 'config.py')) +else: + APP.config.from_pyfile(os.path.join(os.getcwd(), 'config.env.py')) + +APP.secret_key = APP.config['SECRET_KEY'] + +@APP.route('/') +def _index(): + return jsonify(status=200, response="OK") diff --git a/requirements.txt b/requirements.txt index 7b7f48f..4437399 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ Flask==1.1.2 gunicorn==20.0.4 pylint==2.6.0 pylint-quotes==0.2.1 +requests==2.24.0 \ No newline at end of file diff --git a/wsgi.py b/wsgi.py index a498cb4..31fc3f5 100644 --- a/wsgi.py +++ b/wsgi.py @@ -2,7 +2,7 @@ Primary entry point for the app """ -from demo import APP +from poller import APP if __name__ == "__main__": APP.run(host=APP.config["IP"], port=int(APP.config["PORT"])) -- cgit v1.2.3