Created
June 22, 2012 12:32
-
-
Save mitsuhiko/2972483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python routetest.py | |
/ | |
>>> group_list(www2) | |
/aha | |
>>> jot_list(www2, aha, None) | |
/aha:blah | |
>>> jot_list(www2, aha, blah) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
app.config['SERVER_NAME'] = 'lvh.me:5000' | |
# lvh.me:5000 routes back to localhost so you can test subdomains locally | |
# with sub.lvh.me:5000 | |
# sub.lvh.me:5000/ should only trigger this group_list route | |
@app.route('/', subdomain='<area>') | |
def group_list(area='www', group=None, subgroup=None): | |
return "group_list(%s)" % area | |
# but for some reason, this route is also picking it up. | |
# you can see in the console that both group_list & jot_list run | |
@app.route('/<group>:<subgroup>', subdomain='<area>') | |
@app.route('/<group>', subdomain='<area>') | |
def jot_list(area='www', group='general', subgroup=None): | |
return "jot_list(%s, %s, %s)" % (area, group, subgroup) | |
c = app.test_client() | |
def test(url, subdomain='www2'): | |
print url | |
print '>>>', c.get(url, base_url='http://%s.lvh.me:5000/' % subdomain).data | |
test('/') | |
test('/aha') | |
test('/aha:blah') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment