Skip to content

Instantly share code, notes, and snippets.

@clivegross
Created March 28, 2016 14:49
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 clivegross/75326ca40e3ea1e0c790 to your computer and use it in GitHub Desktop.
Save clivegross/75326ca40e3ea1e0c790 to your computer and use it in GitHub Desktop.
Falcon Framework troubleshooting byte string request
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)
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"
}
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()
<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