Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question : Dynamic Subdomains ? #74

Open
depado opened this issue Jan 26, 2015 · 2 comments
Open

Question : Dynamic Subdomains ? #74

depado opened this issue Jan 26, 2015 · 2 comments

Comments

@depado
Copy link

depado commented Jan 26, 2015

Hi !
I was just wondering if there was a way of using a dynamic subdomain with FlaskView ? I know one can define a custom subdomain, but I'd like it to be dynamic. Is there a way I can achieve that ?

Thanks for the good work !

@frankV
Copy link

frankV commented Apr 28, 2015

After looking for a solution to this I think I may have stumbled upon one accidentally. If you want to handle dynamic subdomains you need to decorate your view methods with Flask-Classy's route, here's an example of what I did:

from flask.ext.classy import FlaskView, route
...
@route('/', subdomain='<subdomain>')
def index(self, subdomain):
    objs = self.model().all()
    return render_template('%s/index.html' % self.model.__tablename__.lower(), objs=objs)

@depado
Copy link
Author

depado commented Apr 28, 2015

Thanks @frankV. In the end, I just used BluePrints for my dynamic subdomain handling. But I'll keep that in mind !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants