I will give an example of a project that I am developing, and I had to use to filter the subdomains where to send the URL:
app = webapp2.WSGIApplication([ routes.DomainRoute('api.domain.com', [ webapp2.Route('/', handler=HomeApi, name='subdomain-home'), webapp2.Route('/user', handler=UserApi, name='subdomain-home'), ]), routes.DomainRoute('web.domain.com', [ webapp2.Route('/', handler=HomeApi, name='subdomain-web-home'), webapp2.Route('/login', handler=Login, name='login-home'), webapp2.Route(r'/products/<product_id:\d+>', ProductHandler), ]), webapp2.Route('/', handler=Home, name='home'), webapp2.Route('/contact', handler=Contact, name='home'), ])
if you try online, you will need to add cname to your cpanel of your domain and the admin panel of your application. Additional information: webapp2 - routing URI - routing of the domain and subdomain .
source share