Skip to content

Instantly share code, notes, and snippets.

Created Sep 28, 2020
What would you like to do?
Route to healthy server
#!/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__)
def hello_world():
if state:
return 'Hello, World!'
if __name__ == '__main__':
run_simple('', 5000, app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment