暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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