import os import time from flask import Flask import mysql.connector passfile = open('/run/secrets/db-password', 'r') #give db some time to start time.sleep(3) #connect to db conn = mysql.connector.connect( user='root', password=passfile.read(), host='db', # name of the mysql service as set in the docker-compose file database='example', auth_plugin='mysql_native_password' ) passfile.close() cursor = conn.cursor() app = Flask(__name__) @app.route('/') def listBlog(): cursor.execute('SELECT title FROM blog') response = '' for c in cursor: response = response + '