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):
    """Dynamic subdomains are also supported
    Try going to user1.your-domain.tld/dynamic"""
return username + '.your-domain.tld'
Dynamic Subdomain Handling in a Web App (Flask)