Skip to content

Instantly share code, notes, and snippets.

@moredhel
Last active October 4, 2017 09:37
Show Gist options
  • Save moredhel/fb3b1a52e8b54afffc288dab80a48252 to your computer and use it in GitHub Desktop.
Save moredhel/fb3b1a52e8b54afffc288dab80a48252 to your computer and use it in GitHub Desktop.
import os
from flask import Flask, abort
app = Flask(__name__)
healthy = True
@app.route("/env/var")
def env_var():
return "VAR: {}\n".format(os.environ["VAR"])
@app.route("/")
def root():
return "/toggle to toggle healthyness\n/healthz to get response\n"
@app.route("/toggle")
def hello():
global healthy
healthy = not healthy
return "now {}\n".format(healthy)
@app.route("/healthz")
def healthz():
if healthy:
return "healthy\n"
else:
abort(400)
if __name__ == "__main__":
app.run(debug=True, port=80, host="0.0.0.0")
FROM python:3
COPY requirements.txt /
RUN pip install --no-cache-dir -r /requirements.txt
RUN apt-get update && apt install -y curl
COPY . /data
CMD ["python", "/data/app.py"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment