webpy 获取http头head信息

打印所有的头信息

for k, v in web.ctx.env.items():
        print(k,v)

获取某条头信息

ct = web.ctx.env.get('CONTENT_TYPE')
import web
urls = (
  '/', 'index',
)
app = web.application(urls, globals())
render = web.template.render('templates/')
class index:
    def GET(self):
        return ('name')
    def POST(self):
        i = web.data()
        for k, v in web.ctx.env.items():
            print(k,v)
        ct = web.ctx.env.get('fdsfdsf')
        b = str(i, encoding="utf-8")
        print(b,ct)
        return  b

if __name__ == "__main__":
    app.run()

推荐一个linux命令行网站:https://rootopen.com

你可能感兴趣的:(webpy 获取http头head信息)