Tag Archives: url

web.py中获取当前url路径

web.ctx.homepath + web.ctx.fullpath 如果只使用web.ctx.fullpath的话,在有subapplications的应用中就不对了,在subapplications中web.ctx.fullpath是相对于当前的subapplications的,不是全部的路径 看看web.py的源代码就清楚了,下面是web.ctx的初始化代码: ctx.homedomain = ctx.protocol + ‘://’ + env.get(‘HTTP_HOST’, ‘[unknown]‘) ctx.homepath = os.environ.get(‘REAL_SCRIPT_NAME’, env.get(‘SCRIPT_NAME’, ”)) ctx.home = ctx.homedomain + ctx.homepath ctx.realhome = ctx.home ctx.ip = env.get(‘REMOTE_ADDR’) ctx.method = env.get(‘REQUEST_METHOD’) ctx.path = env.get(‘PATH_INFO’) # http://trac.lighttpd.net/trac/ticket/406 requires: if env.get(‘SERVER_SOFTWARE’, … Continue reading

Posted in Python | Tagged , | Leave a comment