Answer the question
In order to leave comments, you need to log in
How to import a variable in blueprint?
Good afternoon!
In general, I created a blueprint (root) with all routers, after which I created a connection to the database, now I need to somehow use this connection in the root blueprint.
db.py
from flaskext.mysql import MySQL
from config import app
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = 'root'
app.config['MYSQL_DATABASE_DB'] = 'telebot'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
from flask import Flask
from termcolor import colored
from source.root import root
from db import *
app = Flask(__name__, template_folder = 'assets', static_folder='static', static_url_path='/static/admin')
app.register_blueprint(root)
if __name__ == '__main__':
app.secret_key = 'key'
print(colored(' * Application started successfully!', 'blue'))
app.run(debug = True)
mysql
to root? Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question