Created
January 26, 2011 18:19
-
-
Save mcdonc/797155 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# [chrism@thinko ~]$ curl -i -X POST http://127.0.0.1:8080/login | |
# HTTP/1.0 200 OK | |
# Server: PasteWSGIServer/0.5 Python/2.6.5 | |
# Date: Wed, 26 Jan 2011 18:18:22 GMT | |
# Content-Length: 4 | |
# Content-Type: text/plain; charset=UTF-8 | |
# POST[chrism@thinko curl -i http://127.0.0.1:8080/login | |
# HTTP/1.0 200 OK | |
# Server: PasteWSGIServer/0.5 Python/2.6.5 | |
# Date: Wed, 26 Jan 2011 18:18:37 GMT | |
# Content-Length: 3 | |
# Content-Type: text/plain; charset=UTF-8 | |
from paste.httpserver import serve | |
from pyramid.config import Configurator | |
from pyramid_handlers import action | |
class AuthHandler(object): | |
def __init__(self, request): | |
self.request = request | |
@action(renderer='string') | |
def login_GET(self): | |
return 'GET' | |
@action(renderer='string') | |
def login_POST(self): | |
return 'POST' | |
if __name__ == '__main__': | |
config = Configurator() | |
config.include('pyramid_handlers') | |
config.add_handler('login_GET', '/login', request_method='GET', | |
action='login_GET', handler=AuthHandler) | |
config.add_handler('login_POST', '/login', request_method='POST', | |
action='login_POST', handler=AuthHandler) | |
serve(config.make_wsgi_app()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment