Last active
October 4, 2017 09:37
-
-
Save moredhel/fb3b1a52e8b54afffc288dab80a48252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| flask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment