Skip to content

Question : Dynamic Subdomains ? #74

Description

@depado

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 !

Activity

  1. frankV commented on Apr 28, 2015

    @frankV

    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)
  2. depado commented on Apr 28, 2015

    @depado
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions