Skip to content

Instantly share code, notes, and snippets.

@clivegross clivegross/app.py
Created Mar 28, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.