Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Subdomain Handling in a Web App (Flask) [closed]

I'm going to be using flask to create a web application, and part of the application will involve a subdomain (for example, user1.appname.org).

I'm not sure how to go about creating these subdomains dynamically in the flask configuration, or how to deploy them to a production server.

What is the best way of doing this?

like image 713
Bruce Collie Avatar asked Jun 13 '12 19:06

Bruce Collie


1 Answers

All Flask's routing constructs support the subdomain keyword argument (this includes support for route variables).

@app.route("/", 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" 
like image 64
Sean Vieira Avatar answered Sep 24 '22 22:09

Sean Vieira