Skip to content

Instantly share code, notes, and snippets.

@mozillazg
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mozillazg/36b761f663cfc9fe2b10 to your computer and use it in GitHub Desktop.
Save mozillazg/36b761f663cfc9fe2b10 to your computer and use it in GitHub Desktop.
web.py return request headers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import web
urls = (
'/', 'Index',
)
app = web.application(urls, globals())
class Index(object):
def GET(self):
headers = web.ctx.env
for key in headers.copy():
if 'wsgi' in key:
headers.pop(key)
body = json.dumps(headers, indent=2)
print(body)
return body
if __name__ == '__main__':
web.config.debug = True
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment