Created
September 28, 2020 19:52
-
-
Save athoune/03e84a7412519d7e403e9065ce16ca38 to your computer and use it in GitHub Desktop.
Route to healthy server
This file contains 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
#!/usr/bin/env python3 | |
import signal | |
import os | |
from flask import Flask, abort | |
from werkzeug.serving import run_simple | |
state = True | |
def handler(*args): | |
global state | |
state = not state | |
print("swap to %s" % state) | |
signal.signal(signal.SIGHUP, handler) | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
if state: | |
return 'Hello, World!' | |
else: | |
abort(500) | |
if __name__ == '__main__': | |
run_simple('0.0.0.0', 5000, app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment