@app.route('/dynamic', subdomain='<username>')
def username_index(username):
    """Dynamic subdomains are also supported
    Try going to user1.your-domain.tld/dynamic"""
return username + '.your-domain.tld'
Динамическая обработка поддоменов в веб-приложении (Flask)