Last active
December 22, 2015 19:49
-
-
Save chibisov/6522525 to your computer and use it in GitHub Desktop.
Revisions
-
chibisov revised this gist
Sep 24, 2013 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,10 +26,17 @@ import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.set_header('Content-Type', 'text/plain') self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Headers', 'accept, origin, x-requested-with, x-csrftoken, content-type') response = self._get_response() print response self.write(response) head = get post = get put = get patch = get delete = get options = get def _get_response(self): headers_text = '\n'.join( -
chibisov revised this gist
Sep 11, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,9 @@ import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.set_header('Content-Type', 'text/plain') response = self._get_response() print response self.write(response) post = get def _get_response(self): -
chibisov revised this gist
Sep 11, 2013 . 1 changed file with 26 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,25 @@ #!/usr/bin/env python """ $ curl -d 'hello=world' http://localhost:8888/path/?someparam=1 Request URL: http://localhost:8888/path/?someparam=1 Request Method: POST Request Headers: Host: localhost:8888 Content-Type: application/x-www-form-urlencoded Content-Length: 11 Accept: */* User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 Request Body: hello=world Query String Parameters: {"someparam": ["1"], "hello": ["world"]} """ import json import tornado.ioloop import tornado.web @@ -23,11 +44,15 @@ Request Headers: Request Body: {body} Query String Parameters: {query_string_parameters} """.format( request_url=self.request.full_url(), request_method=self.request.method, headers=headers_text, body=self.request.body, query_string_parameters=json.dumps(self.request.arguments) ).lstrip() application = tornado.web.Application([ -
chibisov created this gist
Sep 11, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/usr/bin/env python import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.set_header('Content-Type', 'text/plain') self.write(self._get_response()) post = get def _get_response(self): headers_text = '\n'.join( ['%s: %s' % (header_name, value) for header_name, value in self.request.headers.items()] ) return """ Request URL: {request_url} Request Method: {request_method} Request Headers: {headers} Request Body: {body} """.format( request_url=self.request.full_url(), request_method=self.request.method, headers=headers_text, body=self.request.body ).lstrip() application = tornado.web.Application([ (r".*", MainHandler), ]) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()