All Flask’s routing constructs support the subdomain
keyword argument (this includes support for route variables).
@app.route("https://stackoverflow.com/", subdomain="static")
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"