Created
March 28, 2016 14:49
-
-
Save clivegross/75326ca40e3ea1e0c790 to your computer and use it in GitHub Desktop.
Falcon Framework troubleshooting byte string request
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
class LoginResource(object): | |
def __init__(self, db): | |
self.db = db | |
self.logger = logging.getLogger('test.' + __name__) | |
def on_post(self, req, resp): | |
"""Handles GET requests""" | |
print(req.get_header) | |
print(req.content_type) | |
print(req.get_param('test')) | |
print(req.params) | |
print(req.stream.read().decode('utf-8')) | |
app = falcon.API() | |
app.add_route('/users/login', login) |
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
POST /users/login HTTP/1.1 | |
Host: localhost:5002 | |
Content-Type: application/json | |
Cache-Control: no-cache | |
Postman-Token: d5da931c-0b9e-9aaa-14ba-a9e6201f8ba7 | |
{ | |
"test": "yes" | |
} |
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
from wsgiref import simple_server | |
from test import app | |
# Useful for debugging problems in your API; works with pdb.set_trace() | |
httpd = simple_server.make_server('127.0.0.1', 5002, app) | |
httpd.serve_forever() |
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
<bound method Request.get_header of <falcon.request.Request object at 0x7facb62a70e0>> | |
application/json | |
None | |
{} | |
{ | |
"test": "yes" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment