No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

router.py 456B

1234567891011121314151617181920
  1. # -*- coding: utf-8 -*-
  2. import re
  3. from .controllers import *
  4. from .urls import urls
  5. def get_controller(request):
  6. url_rules = []
  7. for url in urls:
  8. url_rules.append((url[0], url[1]))
  9. # Returning the right controller to call
  10. for regex, callback in url_rules:
  11. match = re.search(regex, request.PATH)
  12. if match is not None:
  13. request.url_args = match.groups()
  14. return callback
  15. return not_found