def static_index():
    """Flask supports static subdomains
    This is available at static.your-domain.tld"""
return 'static.your-domain.tld'

@app.route('/dynamic', subdomain='<username>')
def username_index(username):
    pass
Динамическая обработка поддоменов в веб-приложении (Flask)