A
A
armor2012-08-30 13:05:44
Python
armor, 2012-08-30 13:05:44

Flask blueprint subdomain?

There are two modules for the site itself and for the admin panel. One opens on www.site.ru , the other on admin.site.ru.

main = Blueprint('main', __name__, subdomain='www')
admin = Blueprint('admin', __name__, subdomain='admin')

I want to add a third module that will work as a product catalog, each company on its own subdomain,
for example: hp.site.com or ibm.site.ru. The template is the same, but the bases are different.
Actually, how to configure this module so that it opens on different subdomains? Even better, if not www or admin, then he.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
armor, 2012-09-05
@armor

Found the answer:

sub = Blueprint('sub', __name__, subdomain='<trademark>')
@sub.url_defaults
def add_trademark(endpoint, values):
    values.setdefault('trademark', g.a_trademark)
@sub.url_value_preprocessor
def pull_trademark(endpoint, values):
    g.a_trademark = values.pop('trademark')
    query = City.query.filter(Company.url==g.a_trademark)
    g.trademark = query.first_or_404()

K
klinkin, 2012-09-05
@klinkin

Hello, if you find a solution, write here pliz. The same question is interesting)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question