Created
April 11, 2016 04:36
-
-
Save anish/eb05639e9c4ac1165313311a0ce34986 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
import web | |
import json | |
def add_global_hook(x): | |
g = web.storage({"auth": x}) | |
def _wrapper(handler): | |
web.ctx.globals = g | |
return handler() | |
return _wrapper | |
class hooks: | |
def POST(self): | |
print "%s" % web.ctx.globals.auth['username'] | |
if __name__ == '__main__': | |
with open('test') as f: | |
x = json.load(f) | |
urls = ("/.*", 'hooks') | |
app = web.application(urls, globals()) | |
app.add_processor(add_global_hook(x)) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment