Ask coding questions

← Back to all posts
Dynamic subdomains in Flask? 👀
ayshptk (0)

Yoo I was building a little something which would require to use the dynamic subdomains in flask.

Here's a sample of the code I'm using:

from flask import Flask, request
app = Flask(__name__)

@app.route("/", subdomain="<username>") 
def profile(username):
    return "Hello " + username + "!"

if __name__ == "__main__": host='')

And I added the following CNAME to my Cloudflare:   CNAME ~replit _ custom _ domain _here ~ 
* CNAME ~replit _ custom _ domain _here ~

But doesn't seem to work. This is what I get when I go to a random subdomain:

I know the problem is to send the traffic to my Repl, but can't find a way to do it.

Any help is appreciated, thanks!