Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global timecheck
- app = Flask(__name__)
- dbconn = mysql.connector.connect(host=config["mysql"]["host"],
- database=config["mysql"]["database"], user=config["mysql"]["user"],
- password=config["mysql"]["password"])
- cursor = dbconn.cursor()
- def connect_to_db():
- query = ("update check_if_alive set check_time=%s")
- param = timecheck
- cursor.execute(query, (param,))
- print('Check_time: ' + str(param))
- dbconn.commit()
- @app.route('/', methods=['GET', 'POST'])
- def aggregator():
- if request.method == 'POST':
- timecheck = datetime.datetime.now()
- #connect_to_db()
- return str('OK')
- else:
- print("lost connection to service")
- if __name__ == '__main__':
- t = threading.Timer(30.0, connect_to_db)
- t.start()
- app.run(host="myhost", port=5211)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement